lua-users home
lua-l archive

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


On Thu, Dec 3, 2009 at 1:00 PM, David Kastrup <dak@gnu.org> wrote:
> Is this
> fun2(function(x) return x*x end, x)
> or
> fun2(function(x) return x*x, x end)
> ?

Well, that did shut me up briefly, I'll grant you that.

But I still think that Miles had a valid point when he said that small
expressions can be overwhelmed by the function...return..end
machinery.  Perhaps we are simply so used to anonymous functions that
we have learned to skim over them, much as C etc programmers see that
old nastiness 'for(i = 0; i < n; i++)' as one blob of information?

In Penlight we went to some trouble to introduce placeholder
expressions, so that _1*_1 would resolve as something that could be
_compiled_ to function(x) return x*x end.  But it cannot cover all of
Lua's expression syntax, since 'or' is not an operator, '==' insists
that both arguments are the same type, etc.

It's possible that a relative newbie to Lua would be more comfortable
with the short notation (especially one with mathematical needs),
which modifies one line of the syntax:

   function ::= function funcbody | `|` [parlist] `|` exp

Which BTW, means that it's the first meaning ;)

steve d.