Open Methods: From C++ to D
jmh530 via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu Aug 31 18:36:12 PDT 2017
On Thursday, 31 August 2017 at 16:55:17 UTC, Jean-Louis Leroy
wrote:
>
> Indeed I misunderstood.
>
> Well, I am very pleased that my stuff interacts well with the
> rest of the language - I strive for that. However, I found that
> it is difficult to get people to open their mind to the idea of
> open methods, initially. Unless they come from Lisp,
> polymorphism and membership are almost indissociable for them.
> I often have to jump three hurdles.
>
I can see that it's a uphill battle, but there's a lot to like
about it as well for those who listen.
Maybe it would be a good idea to allow the @method to take an
argument, like @method(Animal), then you could mixin
string kick(virtual!Animal);
without having to define kick.
I think the ideal would be if you could just write something like
below:
@string(Animal)
string kick(virtual!Dog dog) { return "bark"; }
but I don't really know how to get that to work.
More information about the Digitalmars-d-announce
mailing list