#52 Illegal semicolons can be emitted at the beginning of functions 6 months ago

Ticket created by ~jeremypenner on ~technomancy/fennel

Looks like https://git.sr.ht/~technomancy/fennel/commit/3ffd391d7fa3e774056555abd53156bb535d0c39#src/fennel/compiler.fnl is not compatible with LuaJIT in all cases. The following code:

(fn x [y] 

will compile to something like:

local function x(y)
  ; (y.obj):method()
  return y

LuaJIT treats the semicolon in that position as illegal. (In my limited testing, Lua 5.2 and up appear to accept it.)

This is blocking me from using 0.9.0.

#28 Reader macros syntax proposals 10 months ago

Comment by ~jeremypenner on ~technomancy/fennel

"Read-time" in Fennel is not currently super well-documented - I assume in this context we are using it to mean fennel.parser(). One fundamental question: When fennel.parser encounters the text @ordered-set#["a" "b" "c"], what does it do? I see two options with very different consequences:

  1. It calls ordered-set on [:a :b :c] and embeds the result directly into the output. The compiler sees this and treats this as a literal value which evaluates to itself.
  2. It generates a table, something like {:tag :ordered-set :form [:a :b :c]}, with a special marker in the metatable to mark it as a "tagged literal", and embeds that in the output. The compiler sees this and compiles a call to (ordered-set [:a :b :c]).

I was assuming option 1, which IMO is a bad idea. (How do you compile an arbitrary object with metatables and arbitrary functions or even userdata to readable Lua? IMO there's no good way that's not way more trouble than it's worth. Do we attempt to protect against @eval#"(launch-missiles)"?) But all of my objections basically disappear if the reader doesn't execute arbitrary user code directly.

Another question then becomes, how does this interact with macros? Do macros that get passed an @ordered-set#[:a :b :c] see the special unevaluated "tagged literal" table, or do they see an ordered set? If they see an ordered set, we're back into "how do we serialize an arbitrary complex value into Lua code" territory again. But it may be surprising to see a special unevaluated "tagged literal" object and have to take an extra step to turn it into a value the macro can interpret more directly. OTOH, if the "tagged literal" object is exposed to macros, then macros could trivially do things like turn an @ordered-set#[:a :b :c] into a @special-transformed-set#[:a :b :c :d], which could be cool.

#28 Reader macros syntax proposals 10 months ago

Comment by ~jeremypenner on ~technomancy/fennel

I'm trying to understand the semantics here - in what sense, if any, is this not just an alternate syntax for a two-element list? Are we evaluating custom code at parse-time to modify the results of the tree? If so, how does this interact with the compiler if the resulting object doesn't have a reasonable serialization to Lua?

If this is just a different way of writing (foobar.abc [1 2 3]) without parens then I can't see how it justifies its weight.