lua-users home
lua-l archive

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


We need more fire :-)

Inspired by Smalltalk (http://web.cecs.pdx.edu/~black/OOP/Tutorial/SqueakLanguageRef.html, Block Expressions):

    [  statementSequence ]     "block without arguments"
    [  (: identifier)+ | statementSequence ]     "block with arguments"


[ x=1 y=2 return x+y ] "a block which, when evaluated, will answer the value 3"
[ object:doWithSideEffects(); return test] "a block which, when evaluated, will send #doWithSideEffects to object, and answer the object test"
[ :param | return param:doSomething() ] "a block which, when evaluated with a parameter, will answer the result of sending #doSomething to the parameter.

Obviously, leaving away a return, means no return value from the block.


Potentially extensible to include (ducking now :-):

    [ (: identifier)+ | | identifier+ | statementSequence ]      "block with arguments and local variables"


Robby