I cannot seem to figure out how I can add the 'when' keyword to BOO which should behave as an 'if'. I figure I could make a method, but then I cannot move the when around like I can with if. Any pointers would be appreciated.
-Mark
This would do what you want:
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.MetaProgramming
macro when:
return [|
if $(when.Arguments[0]):
$(when.Block)
|]
x = 1
when x == 1:
print "x equals one"
when x == 2:
print "x equals two"
Btw, feel free to (also) ask on the Boo mailing-list to get (more) answers quicker ;)
This would be a job for a macro. From the page you linked to, it seems that Boo has syntactic macros.
As an aside note, why do you need an exact duplicate of an existing functionality?