Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Adding optional parameters to a procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aange10




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
DemonWasp




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: