Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on fennel.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/fennel.e>
#           or at <http://angg.twu.net/e/fennel.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.mailing-list»	(to "mailing-list")
# «.install»		(to "install")
# «.tutorial»		(to "tutorial")
# «.fennel-git»		(to "fennel-git")
# «.fennel.exe»		(to "fennel.exe")
# «.fennel-0.0.1»	(to "fennel-0.0.1")
# «.fennel-lang.git»	(to "fennel-lang.git")
# «.traceback»		(to "traceback")
# «.traceback-email»	(to "traceback-email")
# «.translate»		(to "translate")
# «.fennel-mode»	(to "fennel-mode")
# «.exo-encounter-667»	(to "exo-encounter-667")
# «.test-blocks»	(to "test-blocks")
# «.fennelconf-2021»	(to "fennelconf-2021")
# «.anarres»		(to "anarres")
# «.antifennel»		(to "antifennel")
# «.game-jam-1»		(to "game-jam-1")
# «.reload»		(to "reload")
# «.fnlfmt»		(to "fnlfmt")
# «.edrxlib»		(to "edrxlib")
# «.compile»		(to "compile")
# «.icollect»		(to "icollect")




#####
#
# mailing-list
# 2022nov25
#
#####

# «mailing-list»  (to ".mailing-list")
# https://lists.sr.ht/~technomancy/fennel

# [IDEA] Destructuring in flow control?
# https://lists.sr.ht/~technomancy/fennel/%3Cm2v8je49x1.fsf%40me.com%3E




#####
#
# install
# 2021sep23
#
#####

# «install»  (to ".install")
# https://fennel-lang.org/
# https://fennel-lang.org/setup#downloading-fennel
# https://fennel-lang.org/downloads/fennel-0.10.0
# https://git.sr.ht/~technomancy/fennel/tree/main/item/src/fennel.fnl

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -v    ~/bin/fennel
cp -v $S/https/fennel-lang.org/downloads/fennel-0.10.0 ~/bin/fennel
chmod +x ~/bin/fennel




#####
#
# tutorial
# 2022sep15 / 2022nov23
#
#####

# «tutorial»  (to ".tutorial")
# https://fennel-lang.org/tutorial
# https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/
# https://leafo.net/posts/itchio-and-coroutines.html
# (find-fenneldoc "index")
# (find-fenneldoc "tutorial")

* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)

;; (find-fenneldoc "tutorial#functions-and-lambdas")
(fn print-and-add [a b c]
  (print a)
  (+ b c))

(fn print-sep [sep ...]
  "Prints args as a string, delimited by sep"
  (print (table.concat [...] sep)))
,doc print-sep

(lambda print-calculation [x ?y z]
  (print (- x (* (or ?y 1) z))))

(print-calculation 5) ; -> error: Missing argument z

;; (find-fenneldoc "tutorial#locals-and-variables")

(let [x (+ 89 5.2)
      f (fn [abc] (print (* 2 abc)))]
  (f x))

(local tau-approx 6.28318)

(let [x 19]
  ;; (set x 88) <- not allowed!
  (let [x 88]
    (print (+ x 2))) ; -> 90
  (print x)) ; -> 19

(var x 19)
(set x (+ x 8))
(print x) ; -> 27

;; (find-fenneldoc "tutorial#numbers-and-strings")

(let [x (+ 1 99)
      y (- x 12)
      z 100_000]
  (+ z (/ y 10)))

(.. "hello" " world")

;; (find-fenneldoc "tutorial#tables")

{"key" "value"
 "number" 531
 "f" (fn [x] (+ x 2))}

(let [tbl (function-which-returns-a-table)
      key "a certain key"]
  (. tbl key))

(let [tbl {}
      key1 "a long string"
      key2 12]
  (tset tbl key1 "the first value")
  (tset tbl key2 "the second one")
  tbl) ; -> {"a long string" "the first value" 12 "the second one"}

;; (find-fenneldoc "tutorial#sequential-tables")
;; (find-fenneldoc "tutorial#iteration")
;; (find-fenneldoc "tutorial#looping")
;; (find-fenneldoc "tutorial#conditionals")




#####
#
# fennel-git
# 2021sep23
#
#####

# «fennel-git»  (to ".fennel-git")
# (find-angg ".emacs" "fennel")
# https://git.sr.ht/~technomancy/fennel
# https://git.sr.ht/~technomancy/fennel/tree/main/item/src/fennel.fnl
# (find-git-links "https://git.sr.ht/~technomancy/fennel" "fennel")
# (code-c-d "fennel" "~/usrc/fennel/")
# (find-fennelfile "")
# (find-fennelfile "README.md")
# (find-fennelfile "setup.md")
# (find-fennelfile "Makefile")
# (find-fennelfile "src/")
# (find-fennelfile "src/fennel.fnl")
# (find-fennelfile "src/fennel/")
# (find-fennelsh "find * | sort")

# (find-fennelgrep "grep --color=auto -nRH --null -e comment *")
# (find-fennelgrep "grep --color=auto -nRH --null -e fennelrc *")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rfv ~/usrc/fennel/
cd      ~/usrc/
git clone https://git.sr.ht/~technomancy/fennel
cd      ~/usrc/fennel/

export PAGER=cat
git branch --list -a
git for-each-ref
git log --oneline --graph --all -20

# (find-fline "/tmp/fe/")
rm -Rv /tmp/fe/
mkdir  /tmp/fe/
cd     /tmp/fe/

cd      ~/usrc/fennel/
git reset --hard

     make -f Makefile LUA_VERSION=5.2         |& tee om
sudo make -f Makefile LUA_VERSION=5.2 install |& tee omi

# Uninstall:
sudo rm -fv /usr/local/bin/fennel
sudo rm -fv /usr/local/share/lua/5.4.3/fennel.lua
sudo rm -fv /usr/local/share/lua/5.2/fennel.lua
sudo rm -fv /usr/local/man/man1/fennel.1

* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)
,help

# (find-fline "~/usrc/")
# (find-fline "~/usrc/fennel/")
# (find-gitk  "~/usrc/fennel/")




#####
#
# Building fennel.exe
# 2021nov04
#
#####

# «fennel.exe»  (to ".fennel.exe")
# (find-fline "~/LOGS/2021nov04.lua")
# (find-fline "~/LOGS/2021nov04.lua" "Makefile#L92")
# (code-c-d "fennel" "~/usrc/fennel/")
# (find-fennelfile "")
# (find-fennelfile "Makefile")
# (find-fennelfile "Makefile" "fennel.exe:")
# (find-fennelfile "lua-5.4.3/")
# (find-fennelfile "lua-5.4.3/Makefile")
# (find-fennelfile "lua-5.4.3/src/")
# (find-fennelfile "lua-5.4.3/src/Makefile")
# (find-fennelfile "lua-5.4.3/src/Makefile" "mingw:")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd      ~/usrc/fennel/
git clean -dfx
git reset --hard
make fennel.exe    |& tee omfe

i686-w64-mingw32-gcc

# (find-sh "apt-file search i686-w64-mingw32-gcc")
# (find-status   "gcc-mingw-w64-i686-posix")
# (find-vldifile "gcc-mingw-w64-i686-posix.list")
# (find-udfile   "gcc-mingw-w64-i686-posix/")



#####
#
# fennel-0.0.1
# 2024oct11
#
#####

# «fennel-0.0.1»  (to ".fennel-0.0.1")
# (find-fline "~/LOGS/2024oct11.emacs" "just barely over 1000 lines")
# https://git.sr.ht/~technomancy/fennel/tree/0.0.1/item/fnl.lua





#####
#
# Building a local copy of fennel-lang.org
# 2022nov25
#
#####

# «fennel-lang.git»  (to ".fennel-lang.git")
# https://git.sr.ht/~technomancy/fennel-lang.org
# (find-git-links "https://git.sr.ht/~technomancy/fennel-lang.org" "fennellang")
# (code-c-d "fennellang" "~/usrc/fennel-lang.org/")
# (find-fennellangfile "")
# (find-fennellangfile "Makefile")
# (find-fennellangfile "Makefile" "\nhtml:")
# (find-fennellangfile "Makefile" "Makefile")
# (find-fennellangfile "Makefile" "\nfennelview.lua:")
# (find-fennellangfile "Makefile" "fennel/fennel:")
# (find-es "git" "very-hard-reset")
# (find-node "(make)Options Summary" "-C DIR")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd ~/usrc/fennel-lang.org/
git clean -dfx
git reset --hard
git pull

cd ~/usrc/fennel-lang.org/fennel/
git clone https://git.sr.ht/~technomancy/fennel .

cd ~/usrc/fennel-lang.org/
make   |& tee om

# (find-fenneldoc "tutorial")





#####
#
# traceback
# 2021sep25
#
#####

# «traceback»  (to ".traceback")
# (find-fennelgrep "grep --color=auto -nRH --null -e traceback *")
# (find-fennelgrep "grep --color=auto -nRH --null -e 'function traceback' *")
# (find-fennelfile "bootstrap/fennel.lua" "local function traceback_frame(")
# (find-fennelfile "bootstrap/fennel.lua" "local function traceback(")
# (find-fennelfile "src/fennel/compiler.fnl" "(fn traceback-frame ")
# (find-fennelfile "src/fennel/compiler.fnl" "(fn traceback ")
# https://git.sr.ht/~technomancy/fennel/tree/main/item/src/fennel/compiler.fnl
# (find-fline "~/LOGS/2022jan19.fennel")

* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)
(local REPL (EdrxRepl.new)) (REPL:repl)

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
= os.getenv("LUA_INIT"):sub(2)
dofile(os.getenv("LUA_INIT"):sub(2))




#####
#
# E-mail about traceback - sent to lua-l in 2022mar22
# 2022mar22
#
#####

# «traceback-email»  (to ".traceback-email")
# https://mail.google.com/mail/u/0/#sent/KtbxLzGPrdrsVBJgMPwDggWQLNnXZQTbCL
# Subj: debug.traceback() in Lua?

Hi list,

where can I find a version in Lua of debug.traceback()?
I know that there is one in Fennel... its original code -
in Fennel - is here,

https://git.sr.ht/~technomancy/fennel/tree/main/item/src/fennel/compiler.fnl#L827-873

and we can obtain its translation to Lua by running this:

  rm -Rfv /tmp/fennel/
  cd      /tmp/
  git clone https://git.sr.ht/~technomancy/fennel
  cd      /tmp/fennel/
  make -f Makefile LUA_VERSION=5.2
  awk '2902<=NR && NR<=2963' bootstrap/fennel.lua  | tee tb.lua

After running the code above the file /tmp/fennel/tb.lua
will contain this:

  local function traceback_frame(info)
    if ((info.what == "C") and info.name) then
      return string.format("  [C]: in function '%s'", info.name)
    elseif (info.what == "C") then
      return "  [C]: in ?"
    else
      local remap = sourcemap[info.source]
      if (remap and remap[info.currentline]) then
        if remap[info.currentline][1] then
          info.short_src = sourcemap[("@" .. remap[info.currentline][1])].short_src
        else
          info.short_src = remap.short_src
        end
        info.currentline = (remap[info.currentline][2] or -1)
      else
      end
      if (info.what == "Lua") then
        local function _325_()
          if info.name then
            return ("'" .. info.name .. "'")
          else
            return "?"
          end
        end
        return string.format("  %s:%d: in function %s", info.short_src, info.currentline, _325_())
      elseif (info.short_src == "(tail call)") then
        return "  (tail call)"
      else
        return string.format("  %s:%d: in main chunk", info.short_src, info.currentline)
      end
    end
  end
  local function traceback(msg, start)
    local msg0 = tostring((msg or ""))
    if ((msg0:find("^Compile error") or msg0:find("^Parse error")) and not utils["debug-on?"]("trace")) then
      return msg0
    else
      local lines = {}
      if (msg0:find(":%d+: Compile error") or msg0:find(":%d+: Parse error")) then
        table.insert(lines, msg0)
      else
        local newmsg = msg0:gsub("^[^:]*:%d+:%s+", "runtime error: ")
        table.insert(lines, newmsg)
      end
      table.insert(lines, "stack traceback:")
      local done_3f, level = false, (start or 2)
      while not done_3f do
        do
          local _329_ = debug.getinfo(level, "Sln")
          if (_329_ == nil) then
            done_3f = true
          elseif (nil ~= _329_) then
            local info = _329_
            table.insert(lines, traceback_frame(info))
          else
          end
        end
        level = (level + 1)
      end
      return table.concat(lines, "\n")
    end
  end

This seems to be loosely based on the function db_errorfb in the file
src/ldblib.c of the Lua source, but with several changes... I can try
to modify that code to make it more similar to db_errorfb, but I am
not a good programmer, and that would probably take many hours - and I
think that having other "debug.tracebacks()"s in Lua to compare would
save me a lot of time...

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/#eev
    http://angg.twu.net/dednat6.html
    http://angg.twu.net/dednat6/tug-slides.pdf







#####
#
# translate
# 2021sep23
#
#####

# «translate»  (to ".translate")
# https://fennel-lang.org/see

# (find-fline "~/bin/fennel")





#####
#
# fennel-mode
# 2021sep23
#
#####

# «fennel-mode»  (to ".fennel-mode")
# (find-epackage-links 'fennel-mode "fennelmode" t)
# (find-epackage       'fennel-mode)
# (code-c-d "fennelmode" "~/.emacs.d/elpa/fennel-mode-20221025.1830/")
# (find-fennelmodefile "")




#####
#
# Technomancy's exo-encounter-667
# 2021sep23
#
#####

# «exo-encounter-667»  (to ".exo-encounter-667")
# https://technomancy.itch.io/exo-encounter-667
# https://gitlab.com/technomancy/exo-encounter-667
# (find-git-links "https://gitlab.com/technomancy/exo-encounter-667" "exoencounter667")
# (code-c-d "exoencounter667" "~/usrc/exo-encounter-667/")
# (find-exoencounter667file "")



#####
#
# test-blocks
# 2021sep23
#
#####

# «test-blocks»  (to ".test-blocks")
# (find-angg "FENNEL/test0.fnl")
# (find-fline "~/LOGS/2021sep23.emacs" "autumn-lisp-game-jam-2021")
# (find-fline "~/LOGS/2021sep23.fennel")




#####
#
# fennelconf-2021
# 2022jan13
#
#####

# «fennelconf-2021»  (to ".fennelconf-2021")
# https://conf.fennel-lang.org/2021
# https://conf.fennel-lang.org/v/fennelconf-2021-technomancy.mp4
# https://conf.fennel-lang.org/v/fennelconf-2021-mattykins.mp4
# https://conf.fennel-lang.org/v/fennelconf-2020-technomancy.mp4
# https://conf.fennel-lang.org/v/fennelconf-2021-durrendal.mp4
# https://conf.fennel-lang.org/v/fennelconf-2021-andreyorst.mp4
# https://conf.fennel-lang.org/v/



#####
#
# anarres
# 2022jan24
#
#####

# «anarres»  (to ".anarres")
# https://asciinema.org/a/463816
# https://git.sr.ht/~technomancy/anarres

<technomancy> edrx: it's the "emacs" branch specifically
<technomancy> I thiiiiiiink it's fully self-contained? other than
              needing lua on your machine.




#####
#
# antifennel
# 2022mar27
#
#####

# «antifennel»  (to ".antifennel")
# (find-git-links "https://git.sr.ht/~technomancy/antifennel" "antifennel")
# (code-c-d "antifennel" "~/usrc/antifennel/")
# (find-antifennelfile "")
# (find-antifennelfile "README.md")
# (find-fline "~/LOGS/2022mar27.fennel")
# https://fennel-lang.org/see

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd ~/usrc/antifennel/
git clean -dfx
git reset --hard

make   |& tee om
antifennel

rm -fv ~/bin/antifennel
cp -v antifennel ~/bin/


# (find-status   "luajit")
# (find-vldifile "luajit.list")
# (find-udfile   "luajit/")

cd
antifennel

./antifennel targetfile.lua > targetfile.fnl
./antifennel targetfile.lua > targetfile.fnl




#####
#
# game-jam-1
# 2022jun20
#
#####

# «game-jam-1»  (to ".game-jam-1")
# https://itch.io/jam/fennel-game-jam-1
# https://gitlab.com/alexjgriffith/min-love2d-fennel
# https://technomancy.us/187 in which a game jam is recounted



#####
#
# reload
# 2022nov25
#
#####

# «reload»  (to ".reload")
# (find-fennelgrep "grep --color=auto -nRH --null -e reload *")
# (find-fennelgrep "grep --color=auto -nRHw --null -e reload *")
# (find-fennelfile "src/fennel/repl.fnl" "(fn reload ")
# (find-fennelfile "src/fennel/repl.fnl" "(fn commands.reload ")
# (find-fennellanggrep "grep --color=auto -nH --null -e reload *.html")
# (find-fennellanggrep "grep --color=auto -nwH --null -e reload *.html")



#####
#
# fnlfmt
# 2022nov25
#
#####

# «fnlfmt»  (to ".fnlfmt")
# https://git.sr.ht/~technomancy/fnlfmt
# (find-git-links "https://git.sr.ht/~technomancy/fnlfmt" "fnlfmt")
# (code-c-d "fnlfmt" "~/usrc/fnlfmt/")
# (find-fnlfmtfile "")





#####
#
# Loading edrxlib / lua50init from the fennel repl
# 2022nov26
#
#####

# «edrxlib»  (to ".edrxlib")
# (find-angg "LUA/lua50init.lua" "Repl1.lua")
# (find-fline "~/LOGS/2022nov26.fennel")

* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)
(dofile "/home/edrx/LUA/lua50init.lua")
(run_my_repl_now)



#####
#
# fennel --compile
# 2022nov26
#
#####

# «compile»  (to ".compile")
# (find-sh "fennel --help")
# (find-sh "fennel --help" "--compile")
# (find-fenneldoc "tutorial")
# (find-fennelgrep "grep --color=auto -nRH --null -e compile *")
# (find-fennelfile "src/fennel/compiler.fnl")
# (find-fennelfile "src/fennel/compiler.fnl" "(fn compile-string ")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cat > /tmp/o.fnl <<'%%%'
(fn print-and-add [a b c]
  (print a)
  (+ b c))
%%%

fennel            --compile /tmp/o.fnl
fennel --metadata --compile /tmp/o.fnl

* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)
(let  [{: compile-string} (require :fennel)] (print compile-string))
(local {: compile-string} (require :fennel))

(compile-string "
  (fn print-and-add [a b c]
    (print a)
    (+ b c))
  ")



#####
#
# icollect
# 2023nov26
#
#####

# «icollect»  (to ".icollect")
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGwHpMvnhHhQgQVqRqpBtSHSMhN
# https://lists.sr.ht/~technomancy/fennel/%3C87r0klp1bd.fsf%40hagelb.org%3E








https://git.sr.ht/~technomancy/fennel/tree/main/Makefile#L92





https://git.sr.ht/~technomancy/fennel/tree/main/rationale.md



* (eepitch-fennel)
* (eepitch-kill)
* (eepitch-fennel)

(fn square [a] (* a a))
(square 15)
(fn _G.square [a] (* a a))
(_G.square 15)
((fn [x] (* x x)) 5)
(let [square (fn [x] (* x x))] (square 5))


https://andregarzia.com/2020/06/languages-that-compile-to-lua.html


https://www.facebook.com/forfoxsakewildlife/posts/2642736806023066 Fennel

https://technomancy.us/189 in which interactive development saves the day
https://technomancy.us/197 in which five different paths lead to methods

https://news.ycombinator.com/item?id=31029478 Fennel: A Practical Lisp (mattroelle.com) - Chicken Scheme is embedded in C programs with one line
https://github.com/bakpakin/Fennel/wiki/Cookbook
https://github.com/bakpakin/Fennel/wiki/Repl
https://andreyorst.gitlab.io/posts/2022-09-26-reproducible-research-with-org-mode-fennel-and-love/
https://andreyorst.gitlab.io/posts/2023-03-25-implementing-a-protocol-based-fennel-repl-and-emacs-client/

https://github.com/bakpakin/Fennel/wiki/Repl

https://news.ycombinator.com/item?id=33678782 TIC-80 tiny computer (tic80.com) - Fennel
https://technomancy.us/193 in which many rays are cast
https://conf.fennel-lang.org/2022

https://oylenshpeegul.gitlab.io/blog/posts/20240106/ Tim Heaney - very detailed instructions ***
https://oylenshpeegul.gitlab.io/blog/posts/20240108/ Tim Heaney - Emacs configuration
https://fennel-lang.org/survey/2024





#  Local Variables:
#  coding:               utf-8-unix
#  End: