f7a2c360eff033dc731d789214892ef983b031f6 — Phil Hagelberg 6 months ago 4bc211c
Technically for introduces a local too.
2 files changed, 7 insertions(+), 7 deletions(-)

M anticompiler.fnl
M README.md => README.md +3 -5
@@ 9,7 9,7 @@ no problems.
## Usage

    $ make
    $ antifennel targetfile.lua > targetfile.fnl
    $ ./antifennel targetfile.lua > targetfile.fnl

The `antifennel` script is self-contained and can be moved or
symlinked onto your `$PATH`; all it requires to run is LuaJIT.

@@ 18,7 18,7 @@ Or during development, run without building:

    $ luajit antifennel.lua targetfile.lua > targetfile.fnl

## Current limitations
## Limitations

Requires LuaJIT.

@@ 28,9 28,7 @@ won't parse.

Antifennel will always use `local` even in cases where `let` would be better.

## Inherent Limitations

Fennel code does not support `goto`.
Fennel code does not support `goto`, so neither does Antifennel.

Early returns will compile to very ugly Fennel code, but they should
be correct.

M anticompiler.fnl => anticompiler.fnl +4 -2
@@ 216,9 216,11 @@
                                      (list (sym :lua) :break)))))))

(fn for* [compile scope {: init : last : step : body}]
  (let [subscope (make-scope scope)]
  (let [i (compile scope init.id)
        subscope (make-scope scope)]
    (add-to-scope subscope :param [i])
    (list (sym :for)
          [(compile scope init.id) (compile scope init.value) (compile scope last)
          [i (compile scope init.value) (compile scope last)
           (and step (compile scope step))]
          (unpack (map body (partial compile subscope))))))