class extensions

Michael Deardeuff grignaak at gmail.com
Wed Aug 29 10:23:11 PDT 2007


I am very excited about the future of D. Walter's and Andrei's talk at the conference was awesome.

However, there are still a few quirks to get out:
This is regarding slide 9 of the presentation.

I noticed that most people at the conference liked the idea of extending library classes, but were not to pleased with the interchangability of 
---
foo(a, args)
---
and
---
a.foo(args)
---
like the arrays have.

I have a suggestion: class extensions kindof like C#'s partial classes
----
class A {...}
...
extension class A {
   void foo(args) {...}
}
...
a.foo(args);
----
(maybe the syntax could be "class extension A" or "extension A"...)

In this way class extensions are clearly marked and the syntax is consistent.

It would be easy to add interfaces to the library class:

extension A : Visitable {
   void accept(Visitor v) {...}
}

Just an idea for you guys, Walter, Andrei, and the community.

--Michael Deardeuff




More information about the Digitalmars-d mailing list