lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sat, Nov 27, 2010 at 7:19 AM, Dirk Laurie <> wrote:
> The ASCII representation for that, taking into account that Lua
> represents an m-tuple as a table, is
>    {a,b,c,d}->{f,g,h}
> C programmers will have to suppress their instincts, but otherwise
> it's not that unreadable.

Something like
  (a,b,c,d) |-> (f,g,h),
with parentheses and "|->" (\mapsto), makes much more sense than
your proposal... in the preprint below this idea is taken to the extreme:
The "dictionary trick" mentioned in the paper can be implemented
in Lua like this:
  _G["a,b |-> a*b, a-b, {a, b}"] =
    function (a,b) return a*b, a-b, {a, b} end
It is possible to recognize some kinds of "... |-> ..." names
automatically and make the compiler infer the corresponding
functions - that's a kind of "term inference" - but my impression
is that the class of terms that we would like the compiler/interpreter to
recognize is not bounded... we will always want it to recognize more,
and some of the terms that we would like to be recognizable are
going to contain ambiguities that are hard to resolve.

    Eduardo Ochs