Computer Science Canada Optional Procedure and Function parameters |
Author: | Tyr_God_Of_War [ Tue Dec 09, 2008 9:44 pm ] |
Post subject: | Optional Procedure and Function parameters |
Can you create optional parameters? example: intstr ( i : int [ , width : int [ , base : int ] ] ) : string The width and base parameters are optional. |
Author: | Insectoid [ Tue Dec 09, 2008 9:48 pm ] |
Post subject: | RE:Optional Procedure and Function parameters |
umm..not in my knowledge. In languages like Perl it is definitely possible, though nothing is really to be gained by it. Why would you want to? |
Author: | Tony [ Tue Dec 09, 2008 9:51 pm ] |
Post subject: | RE:Optional Procedure and Function parameters |
because sometimes you might want to specify one of many arguments to be some value other than a default one. Turing might have a way (or a workaround to the same effect), but I'm not sure. |
Author: | Vermette [ Tue Dec 09, 2008 9:56 pm ] |
Post subject: | Re: Optional Procedure and Function parameters |
Just some clarification; are you referring to Overloading, or Variadics? |
Author: | Tyr_God_Of_War [ Wed Dec 10, 2008 12:00 am ] |
Post subject: | RE:Optional Procedure and Function parameters |
I wanted to do something just like the intstr or strint functions; where if you omit parameters a default value is used instead. I would gladly use either one if possible in Turing. Variadics would be easier to do what I had in mind, however. |
Author: | [Gandalf] [ Wed Dec 10, 2008 2:02 am ] |
Post subject: | RE:Optional Procedure and Function parameters |
Sadly, Turing offers neither. Though I suppose you can override procedures in inherited classes, but that's not really what you're looking for. intstr() and others work as they do because they are programmed into the Turing environment/compiler/interpreter in C or C++. |
Author: | drij [ Fri Dec 12, 2008 2:41 pm ] | ||
Post subject: | Re: Optional Procedure and Function parameters | ||
Workaround:
It's not really what you asked for, but it's about the closest you can come in Turing. |
Author: | Tyr_God_Of_War [ Sat Dec 13, 2008 9:57 pm ] |
Post subject: | RE:Optional Procedure and Function parameters |
Well, thanks anyway. |