Proposal: Extension Methods

Nick Sabalausky a at a.a
Mon May 12 10:59:24 PDT 2008


"Fawzi Mohamed" <fmohamed at mac.com> wrote in message 
news:g09ivq$6bk$1 at digitalmars.com...
> I find this kind of extensions nice, they allow to work around library 
> misdesign (or to handle special cases) in a much better way.
> Dynamic language often can do it.
> A static language language that had the idea of a posteriori extension 
> very well developed:
> http://www.aldor.org/docs/HTML/chap10.html
> (the language itself is basically dead but for other reasons)
> The question is how difficult is their implementation, and how useful they 
> really are, as these  can lead also to bad design if overused, but well 
> used they are really nice.
>

I didn't read that page very closely, but it sounds like the extensions in 
Aldor are true members of the class they're extending and able to access 
private members? If so, that's the first time I've seen that in a static 
language (Which is kind of interesting). It also sounds kind of like partial 
classes, but with the original class not needing to be declared as partial.

Maybe it's just an unsubstantiated gut feeling, but that stikes me as either 
breaking encapsulation, or possibly causing trouble for dynamic linking (ie, 
one assembly's version of the class has the methods, and another assembly's 
version doesn't - but then, couldn't that affect C#'s partial classes too? I 
wonder how they solved it?), or otherwise reducing some of the benefits of 
strong static typing. 





More information about the Digitalmars-d mailing list