View Single Post
  #1  
Old 12-20-2011, 02:46 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Lightbulb Comma operator, TStaticVar literals

Comma operator
The associativity of the comma operator should be left-associative. The order of execution for its operands is reversed.

PHP Code:
temp.5temp.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.vtemp.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?
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 12-20-2011 at 08:32 PM..
Reply With Quote