[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight syntax: a dissident view
- From: HyperHacker <hyperhacker@...>
- Date: Thu, 25 Nov 2010 17:24:48 -0700
On Thu, Nov 25, 2010 at 15:17, Axel Kittenberger <axkibe@gmail.com> wrote:
>> Say myfunc() returns 3 values. Should they get truncated to 1 value by
>> the lambda? Parentheses around a function call will ordinarily
>> truncate it to one value - but that is confusingly at-odds with having
>> optional parentheses around lambda return values.
>>
>> Simplicity is not so easily achieved :)
>
> Ouch, you're right there, on both statements.
>
>
Why not simply "lambda(x) x == 2 end", then? I agree that most of
these suggestions are ugly and Perlish, and while there's nothing
wrong with Perl, Lua isn't Perl and thus shouldn't look like it,
especially only in certain cases like this.
Similar options:
f = fn(x,y) x+y --translates to: f = function(x,y) return x+y end
f = fn(x,y) do foo() return x+y end --translates to f = function(x,y)
foo() return x+y end
(that is, if a "do" follows the closing parenthesis, the "return" and
"end" are not added automatically, and the "do" is eaten.)
"fn" of course could be "lambda" or similar too but it seems like most
people here are trying to make it as short as possible.
--
Sent from my toaster.
- References:
- Re: Re: Re: Lightweight syntax: a dissident view, Gunnar Zötl
- Re: Re: Re: Lightweight syntax: a dissident view, Luis Carvalho
- Re: Re: Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Re: Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Re: Re: Lightweight syntax: a dissident view, Roberto Ierusalimschy
- Re: Re: Re: Lightweight syntax: a dissident view, Mateusz Czaplinski
- Re: Re: Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Lightweight syntax: a dissident view, Philippe Lhoste
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Mark Hamburg
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Lightweight syntax: a dissident view, Duncan Cross
- Re: Lightweight syntax: a dissident view, Axel Kittenberger