Ticket #1 (accepted defect)

Opened 9 months ago

Last modified 7 months ago

Extension methods and properties

Reported by: Chuck.Esterbrook Owned by: Chuck
Priority: major Milestone:
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

Changed 9 months ago by Chuck

  • status changed from new to accepted

Changed 7 months ago by Chuck

  • component changed from component1 to Cobra Compiler

This was partially done in Cobra 0.8.

Note: See TracTickets for help on using tickets.