[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Another example for syntactically lightweight closures
- From: Fabien <fleutot+lua@...>
- Date: Fri, 8 Feb 2008 08:53:24 +0100
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.