Ticket #1 (accepted enhancement)
Extension methods and properties
Reported by: | Chuck.Esterbrook | Owned by: | Chuck |
---|---|---|---|
Priority: | major | Milestone: | Cobra 0.9 |
Component: | Cobra Compiler | Version: | |
Keywords: | Cc: |
Description
Support extension methods and properties on existing classes, interfaces and structs whether they come from DLLs or declarations.
This feature is found in Smalltalk, Objective-C (categories), C#, VB and others. C# and VB do it on .NET 3.5, but Cobra is still targeting 2.0 and will support it there. The syntax will be:
extend Foo
def bar
pass
get baz as int
return 1
One interesting question is whether or not to allow a nil receiver. C# does which, imo, is quite strange. For "obj.Foo()" in C# you need to know if Foo() is declared in obj's type or outside of it to know whether or not you can pass nil.
Change History
Note: See
TracTickets for help on using
tickets.