With the unified parser, we can now start improving the syntax.
One area that may benefit from changes is the "if" function.
Traditional MilkDrop syntax would be something like this:
per_frame=foo=if(bar, sin(time), 1-cos(time))
Our parser already allows omitting the per_frame= (provided
there's one somewhere earlier) and nicer formatting. E.g.,
foo = if(bar,
sin(time),
1-cos(time))
Now, we could introduce a somewhat C-like if construct looking
like this:
foo = if (bar) sin(time) else 1-cos(time)
Less crowded:
foo = if (bar)
sin(time)
else
1-cos(time)
This would avoid the parentheses around everything, at least if
there's no other term following the if-else. With more terms, it
would get a little more cluttered, maybe looking like this, with
very C-like indentation:
foo = (
if (bar)
sin(time)
else
1-cos(time)
)+blah
We could also have C's ternary operator just like in the original,
which happens to be reasonably easy on the eye:
foo = bar ? sin(time) : 1-cos(time)
or, particularly if the expressions get longer,
foo = bar ?
sin(time) :
1-cos(time)
At the end of each assignment there could also be a semicolon.
Semicolons inside the expression would be disallowed, though.
Opinions ?
- Werner
_______________________________________________
http://lists.milkymist.org/listinfo.cgi/devel-milkymist.org
IRC: #milkymist@Freenode