Optional Function Parameters

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Optional Function Parameters
Infiltrator
Member # 154
Profile #0
It really doesn't make much sense to do...message_dialog("Something","");A more sensible approach would be:message_dialog("Something");, where the second parameter is optional (can be treated as if it isn't there), but can be supplied if you want to use it.

This syntax is commonly signified using the following syntax:void message_dialog(string string1[, string string2]);Would be a good timesaving idea, and makes for cleaner code.

--------------------
Apparently still annoying.
Posts: 612 | Registered: Saturday, October 13 2001 07:00
Agent
Member # 2820
Profile #1
It's just easier to program an application that has to take in all values, including null ones. Otherwise, it has to fill in other values and may have to do a bit of guessing.

This is the same reason why the W3 wants us to use XHTML instead of sloppy web design.

--------------------
Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are.
====
Alorael: War and violence would end if we all had each other's babies!
====
Drakefyre: Those are hideous mangos.
Posts: 1415 | Registered: Thursday, March 27 2003 08:00
Shock Trooper
Member # 4180
Profile #2
quote:
Originally written by Grey-Eyed Stranger:

Would be a good timesaving idea, and makes for cleaner code.
Timesaving? Three or four keystrokes (depending on whether you omit or use spaces between parameters). I don't know about you, but I don't make enough message_dialog calls (or any other calls with null parms, either) for that to add up to much. :)

As for cleaner code, I'd say it's a matter of opinion. It could be argued it leads to sloppier code, as well as confusion when newbs don't realize you CAN pass more than one parm to a particular call.

Regardless, this would be low on my own personal list of changes I'd like to see made to Avernumscript. For the amount of time it would take JV to implement, I'm not sure all of us combined would save enough of our own time to balance. :D

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00
Triad Mage
Member # 7
Profile Homepage #3
Overloading a method/function is simple and doesn't take that much work at all.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Shock Trooper
Member # 4180
Profile #4
You're presuming JV's interpreter can handle C++-style overrides with aplomb. I have my doubts about that.

--------------------
-spyderbytes
Posts: 200 | Registered: Wednesday, March 31 2004 08:00