Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Feature request
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #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 Send a message via Skype™ 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.

Graal Script 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):
Graal Script 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:
Graal Script 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:
Graal Script 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
  #2  
Old 12-27-2011, 12:22 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
No because I dont understand it, although the song is xD
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #3  
Old 12-30-2011, 02:19 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Will check the comma thing. The object creator via {} could be interesting, we are trying to make things more close to javascript so that would fill a gap.
Reply With Quote
  #4  
Old 12-30-2011, 04:26 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Admins View Post
Will check the comma thing. The object creator via {} could be interesting, we are trying to make things more close to javascript so that would fill a gap.
Nice
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:41 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.