Prashant Deva built a Mantra plug-in for Eclipse that does syntax highlighting and such for Mantra. Portions of the code are Eclipse EPL licensed; rest written by Prashant.
I realized that we need the notion of a tuple like Python. List [1,2] is fundamentally an ordered thing not an aggregate of two elements. A tuple (1,2) treats those as separate elements whereas I can think of the list as one thing if I pass it to a function. A tuple is not accessed like a list and really is used to only hold multiple values. I could use this for parallel assignment, but I don't have that and I'm not sure I want it. I decided that we really needed tuples so that we can do parallel iteration using closures:
which prints:
The a and b get mapped to the arguments of closure x and y. Greg Benson, another professor here at the University of San Francisco, suggested that that was pretty unintuitive notation. He persuaded me that the Python syntax is not bad so I added it as a special case of the list literal:
Underneath, of course, it is implemented simply as the above closure applied to a tuple. Here is a set of tests:
which emits:
You can now refer to any regular Java object from within mantra simply by using a variant on the import statement:
Field access works as well
for now, it translates only string and integer objects to mantra objects. For other objects, it leads them as Java objects wrapped in a JavaProxyObject.
imports allowed with main programs / scripts now.
added for-each construct.