Computer Science Canada Default values for function? |
Author: | Jay [ Tue Feb 22, 2005 10:58 am ] |
Post subject: | Default values for function? |
Hey all, I've google'd and searched all this forum, and now I'm finally desperate and posting. Is there any way in Turing to have default values for a function's parameters? I can't find anything that points one way or the other, but I figure if I haven't found anything by now there's probably no way. I also wanted to use function overloading, but found a thread that confirms that that's not possible. Thanks. |
Author: | Tony [ Tue Feb 22, 2005 1:42 pm ] | ||||
Post subject: | |||||
there's a way to fake function overload in Turing. You'd have to use pointers to functions and when you want to overload something, just change the pointer to a new function. Should work. As for default values : there're two approaches to the problem. 1) make all of arguments be string, and if NULL ("") is passed, you make it a default value instead. For integers and floats you can use strint() and strreal().
2) Might be a more interesting approach: accepting an array of arguments. The size will be flexable, it is actually possible to incorporate multiple constructors for the same function.. (hardcoded overloading?)
|
Author: | Jay [ Tue Feb 22, 2005 4:41 pm ] |
Post subject: | |
Thanks for the help. |