Mon Dec 28 01:42:26 CET 2015


It seems not possible to match on the value of variable in a local function

(defun foo
       [(max) (letrec
                ((loop ([max]   'end)
                       ([other] (loop (+ 1 other))))))])

Maybe because these are not "real" lambdas.  My guess is that they
need to be lifted to top level functions to make them recursive, and
those don't have context so can't do this kind of matching in the
VM...  Likely a case or if statement is needed.

EDIT: Running into more cases like this.  Is it impossible to match on
the conents of variables?

From user_guide.txt:

  Repeated variables are *NOT* supported in patterns, there is no
  automatic comparison of values. It must explicitly be done in a

This is quite annoying, coming from Erlang.  Any way to solve it with
a macro?  Maybe think about it, to try to understand why this
restriction arose.

Some more tangential information:
"no repeated variables" == "linearity condition on pattern matching"