[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Another example for syntactically lightweight closures
- From: Mark Hamburg <mhamburg@...>
- Date: Fri, 08 Feb 2008 10:31:02 -0800
on 2/7/08 11:53 PM, Fabien at fleutot+lua@gmail.com wrote:
>
>> A more elaborate example:
>> t :where |x| x.shoesize > 7 :sort |a,b| a.age < b.age :print
>
> This would read as the invocation of method sort on number 7. You probably
> don't want to allow to pass them as parentheses-less parameters.
>
> Notice also that such short functions can used at the beginning of a
> statement, as in (|x| print(x))(42). You might therefore have to use
> statements separators for things like: "(|x|foo(x)) (y) (|x|foo(x)) (y)",
> which can be two statements or a currified 4 parameters function.
This could argue for a syntax more like:
t :where<< x | x.shoesize > 7 >>
:sort<< a, b | a.age < b.age >>
:print()
I haven't looked into whether there are lookahead issue if one wanted to
make the | optional in functions without parameters.
Mark