Paste: newclay bracket lambda syntax

Author: j
Mode: text
Date: Sun, 20 Mar 2011 17:45:40
Plain Text |
Lambda -> "[" LambdaArgs? LambdaBody "]"

LambdaArgs -> ArgumentList ("->" | "=>")

LambdaBody -> Block
            | Statement* ReturnExprList

examples:

[] // take no arguments; return no values
[1] // take no arguments; return 1
[y] // take no arguments; return y captured by reference
[-> y] // same as above, but explicit capture by reference
[=> y] // take no arguments; return y captured by value
[x -> x + y] // take argument "x"; capture "y" by reference
[x => x + y] // capture "y" by value
[ref x:Int -> x += y; ref x] // take ref argument "x"; return "x" by ref
[ref x:Int -> {
    x += y;
    return ref x;
}] // same as previous, but with block syntax

New Annotation

Summary:
Author:
Mode:
Body: