Computer Science Canada

Adding optional parameters to a procedure

Author:  Aange10 [ Mon Apr 23, 2012 4:44 pm ]
Post subject:  Adding optional parameters to a procedure

Pretty much my qestion is in the title.

I recall reading in the documentation that

Turing:

proc myProcedure (variableOne : int, [variableTwo : string])
end myProcedure


The above syntax would allow variableOne to be mandatory, and variableTwo to be an optional input. However I get warning (not error) messages when running code like this in my program. Is this incorrect?

Author:  Tony [ Mon Apr 23, 2012 5:33 pm ]
Post subject:  RE:Adding optional parameters to a procedure

you want function overloading
code:

proc myProc(foo : int, bar : string)
  % do stuff
end myProc

proc myProc(foo : int)
   myProc(foo, "default string")
end myProc

Author:  DemonWasp [ Mon Apr 23, 2012 6:22 pm ]
Post subject:  RE:Adding optional parameters to a procedure

Unfortunately, Turing doesn't actually allow either overloading or variable arguments (varargs).

Basically only Turing's original developers get those privileges.


: