This project has moved and is read-only. For the latest updates, please go here.

How to handle optional parameters in a funciton call

Sep 3, 2009 at 10:59 AM

How to handle optional parameters in a function call

for example 


in the above function call param2 ia an optional parameter. how to write BNF rule for the same

Sep 14, 2009 at 4:28 AM

Don't quite understand... First of all, in most cases (languages), it is not allowed to have optional parameter in the middle, it should always be the last, or one of the last set of parameters all of which are optional. So for ABC, param3 should be optional also.

Next, optionality is usually described in the declaration by special means, like default value, or keyword "optional". So, just describe the construct in a BNF rule...


PS sorry for delay in reply, was on vacation for a few days

Sep 14, 2009 at 12:52 PM

Thanks for your reply.


if parameter 3 and 4 of the above function are optional, can i write BNF rule as follows

paramter.Expression = param1+ comma+param2+ comma+param3+ comma+param4 | param1+ comma+param2+ comma+param3+ Comma | param1+ comma+param2+ comma+ Comma+param4 | param1+ comma+param2+ comma+ Comma



Sep 15, 2009 at 4:36 PM

You don't need to "describe" parameter section for you function like this; you should just use general LIST of parameters - using MakeStarList method - out of a single parameter definition. Look at examples, for ex. c# sample.