Ticket #325 (closed enhancement: fixed)
Move to .Net 4.0: Support Optional Parameters
Reported by: | hopscc | Owned by: | Chuck |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Cobra Compiler | Version: | 0.9.4 |
Keywords: | Cc: |
Description
C# .Net 4.0 supports optional parameters (default parameter values) on method calls.
Enhance cobra to do same.
This would allow methods (and hopefully initializers) to be called without multiple convenience overloads being declared.
See C# 4.0 New Features for C# examples
the obvious Cobra equivalent would be something like
def Process( data as String, ignoreWS as bool = false, moreData as ArrayList? = nil ) pass # actual work done here
called as
Process( "foo", false, nil ) Process( "foo", false ) Process( "foo" )
Replacing
def Process( data as String ) Process( data, false ) def Process( data as String, ignoreWS as Bool ) Process( data, ignoreWS, nil ) def Process( data as String, ignoreWS as Bool, moreData as ArrayList? ) pass # Actual work done here
Try and support initializer declaration (removing initializer chaining the same way) - assuming C# supports this on ctors (?)
If you use the same syntax as above (ideally):
- watch out for complications from handling immediate property assignment in Constructors.
- watch out for erroneous expression token capture between typing and assignment (see ticket:34)
(an obvious enhancement to this is type inference on optional params since an assignment like form give the possibility of inferring the param type).
Attachments
Change History
Note: See
TracTickets for help on using
tickets.