Details
Description
Adding macro operators to the lang, so this is now legal:
a = [1,2,3]
b = 3
print a contains b
This works very much like AstMacros, we have AbstractAstOperatorMacro, which allows us to do arbitrary AST transfroms, and we also default to turning "a contains b" to "a.Contains(b)" if we can't find the relevant macro. Note that we apply pascal casing if needed.
Known issues:
1/
This is legal:
[1,2,3] contains 3
But this is not:
a = [1,2,3]
b = 3
a contains b
That is because the parser tries to read this as a macro statement, and then errors on the b.
2/ unary operators
Let's up discuss this feature and eventually merge it
1) Oren I think you forgot to include parser changes in your patch?
2) What is the problem with "operators-2.boo.not-implemented"?
3) I think we should implement a more booish way to declare such macros than explicitly subclassing AbstractAstOperatorMacro.
How about:
This would require only a small change in MacroMacro, makes it terse and look good/self-explaining imho, and does not add one more top-level macro in the namespace.