
-----------------------------------
Tyr_God_Of_War
Tue Dec 09, 2008 9:44 pm

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.

-----------------------------------
Insectoid
Tue Dec 09, 2008 9:48 pm

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?

-----------------------------------
Tony
Tue Dec 09, 2008 9:51 pm

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.

-----------------------------------
Vermette
Tue Dec 09, 2008 9:56 pm

Re: Optional Procedure and Function parameters
-----------------------------------
Just some clarification; are you referring to [url=http://en.wikipedia.org/wiki/Overload_(programming)]Overloading, or [url=http://en.wikipedia.org/wiki/Variadic_function]Variadics?

-----------------------------------
Tyr_God_Of_War
Wed Dec 10, 2008 12:00 am

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.

-----------------------------------
[Gandalf]
Wed Dec 10, 2008 2:02 am

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++.

-----------------------------------
drij
Fri Dec 12, 2008 2:41 pm

Re: Optional Procedure and Function parameters
-----------------------------------
Workaround:
procedure full (param_1, param_2, param_3)
     /* Code Here */
end full

procedure shorter (param_1, param_2)
     full (param_1, param_2, {param_3 Default Value})
end shorter

procedure shortest (param_1)
     shorter (param_1, {param_2 Default Value})
end shortest 

It's not really what you asked for, but it's about the closest you can come in Turing.

-----------------------------------
Tyr_God_Of_War
Sat Dec 13, 2008 9:57 pm

RE:Optional Procedure and Function parameters
-----------------------------------
Well, thanks anyway.
