~technomancy

WA, USA

https://technomancy.us

tryin' to catch the last train out of Omelas

Trackers

~technomancy/fennel

Last active 13 hours ago

#108 Compiling with Lua 5.1 results in a degenerate fennel.lua 2 days ago

Comment by ~technomancy on ~technomancy/fennel

shtwzrd referenced this ticket in commit 03c1c95.

REPORTED RESOLVED FIXED

#107 Support ending a module with a comment form 5 days ago

enhancement added by ~technomancy on ~technomancy/fennel

#107 Support ending a module with a comment form 5 days ago

Ticket created by ~technomancy on ~technomancy/fennel

Right now if you put a (comment ...) as the last thing in a file, it will result in a module that returns nil. It would be better if you could still return a table from a module even when that style of comment is used there.

Should we reconsider the role of (comment ...) more broadly, or should we just make this one change to how it behaves at the end of a file?

#104 Nested matching 5 days ago

Comment by ~technomancy on ~technomancy/fennel

I've added support for an else clause which can be used as a single place to do all your error handling if there is a mismatch:

(match-> (hello)
  {: a : b} (process-ab a b)
  [one two & rest] (keep-processing (+ one two) rest)
  {: result} (print result)
  (else
   [] (print "Not enough results to continue.")
   (nil msg) (print "Could not process!" msg)))

#106 Makefile: LUA_LIB_DIR is always /share/lua/5.4.3 5 days ago

Comment by ~technomancy on ~technomancy/fennel

Oops; looks like I forgot to pull first. It's up now.

REPORTED RESOLVED FIXED

#106 Makefile: LUA_LIB_DIR is always /share/lua/5.4.3 6 days ago

Comment by ~technomancy on ~technomancy/fennel

Good catch.

The problem here is that the makefile is conflating settings for running and compiling the Fennel->Lua vs settings used specifically for compiling the Fennel binaries.

I've renamed the variables to make it clearer that the second set is specific to creating the binaries. Does that take care of things?

#104 Nested matching 15 days ago

Comment by ~technomancy on ~technomancy/fennel

#104 Nested matching a month ago

Comment by ~technomancy on ~technomancy/fennel

It's true that making it work like let would make the pairing more obvious. But Clojure's when-let does not work the way you described; it specifically disallows having multiple bindings because (according to Rich) it would be unclear whether they would be ANDed or ORed together.

Here's an example which makes it more let-like:

(match-let [{: filename} (get-file-info-for user)
            file (io.open filename :w)
            file (file:write data)]
  (notify user))

The disadvantage here is that it this is less clear about what would happen in the case of the match failing. The semantics we want are for the body to be returned (so the nil+error-msg value can propagate) but it's not clear at all by looking at it that the body will not get evaluated in that case.

The match-> arrow form (by analogy to -?>) is a lot clearer about that.

#104 Nested matching a month ago

enhancement added by ~technomancy on ~technomancy/fennel

#104 Nested matching a month ago

Ticket created by ~technomancy on ~technomancy/fennel

One common pattern with pattern matching is that you "drill down" thru a number of steps which could possibly fail and the result of one pattern match becomes the input to another. This is very awkward right now in Fennel; you end up with something like:

(match (get-file-name-for user)
  filename (match (io.open filename :w)
             f (match (f:write data)
                 f (notify user)
                 (_ msg) (print "could not write data"))
             (_ msg) (print "could not open file" msg))
  _ (print "no file for this user"))

Rather than requiring this degree of nesting, we should consider an alternate matching form which can allow for the value from each clause to be matched by the next. If at any stage it does not match, the entire form returns the value (or values) which don't match. Perhaps something like this:

(match-> (get-file-name-for user)
  filename (io.open filename :w)
  file (file:write data)
  file (notify user))

This is similar to the with form in Elixir: https://hexdocs.pm/elixir/Kernel.SpecialForms.html#with/1