Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-04-2011, 08:23 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Function arguments with default values

You know what would be *really* awesome? If you could define a default value to function arguments, Python style.

PHP Code:
function argumentTest(temp.foobartemp.barfoo=true
In the above example, temp.barfoo would be set to true if a value isn't defined in the function caller.

Can haz plz?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 10-04-2011, 04:36 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Graal just treats undefined variables as null, so why not just do something like this?
PHP Code:
function argumentTest(temp.foobartemp.barfoo) {
  
temp.barfoo temp.barfoo == null true temp.barfoo;
  
// ...

__________________
Reply With Quote
  #3  
Old 10-04-2011, 05:18 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by salesman View Post
Graal just treats undefined variables as null, so why not just do something like this?
PHP Code:
function argumentTest(temp.foobartemp.barfoo) {
  
temp.barfoo temp.barfoo == null true temp.barfoo;
  
// ...

Because of convenience mainly, just like most of the other suggestions posted here.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 10-04-2011, 05:37 PM
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
Better yet, || and && shouldn't return boolean, but rather the last-evaluated operand:

PHP Code:
function foo(bar,baz) {
  
bar bar || true;
  
baz baz || "Hey, how're you doin'? ;)";

e: You saw nothing.
e2: Actually, if || and && are using the same optimization as here, that would have to change for this to make any sense.

But perhaps we could just have ||= and &&=

PHP Code:
function foo(bar,baz) {
  
bar ||= true;
  
baz ||= "Hey, how're you doin'? ;)";

__________________
◕‿‿◕ · 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; 10-04-2011 at 05:47 PM..
Reply With Quote
Reply


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 09:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.