How to handle optional parameters in a funciton call

Sep 3, 2009 at 9:59 AM

How to handle optional parameters in a function call

for example 

ABC(param1,[param2],param3)

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

Coordinator
Sep 14, 2009 at 3: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...

Roman

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

Sep 14, 2009 at 11:52 AM

Thanks for your reply.

ABC(param1,param2,[param3],[param4])

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

 Thanks

Valarmathi

Coordinator
Sep 15, 2009 at 3: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.