Comma operator
The associativity of the comma operator should be left-associative. The order of execution for its operands is reversed.
PHP Code:
temp.a = 5, temp.b = temp.a;
Will not do what I'd expect. Instead, the operations have to be reversed to get the desired effect, which is confusing.
The same can be said of array literals and argument lists.
This is troublesome for when we have an iterator-type object (say it has a method called
next):
PHP Code:
temp.next_few_lines = { iter.next(), iter.next(), iter.next(), iter.next() };
and then the values are out of order.
TStaticVar literals
The notation I'm proposing would come straight from C:
PHP Code:
{
.foo = "bar",
.baz = "qux",
.lumberjack = {
.spam = "eggs",
.knights = "ni",
.care = function () { return false; }
}
}
This would be useful for creating functions with a variable number of (named) arguments.
Consider then the code to add default values:
PHP Code:
function extend(a,b) { // shared.extend, one day...
temp.dvnb = b.getdynamicvarnames();
temp.dvna = a.getdynamicvarnames();
for (temp.v: temp.dvnb) {
if (b.(@ temp.v).objecttype() == "TStaticVar") {
if (a.(@ temp.v) == NULL)
a.(@ temp.v) = new TStaticVar();
extend(a.(@ temp.v), b.(@ temp.v));
} elseif (a.(@ temp.v) == NULL && ! (temp.v in temp.dvna)) {
a.(@ temp.v) = b.(@ temp.v);
}
}
}
function PlayMozart(input) {
extend(input, { .key = "G", .song = "Eine kleine Nachtmusik" });
switch(input.key) {
case "C#":
case "Db":
// ...
}
}
Now, isn't that pretty?