tardy v0.0.1 - Runtime polymorphism without inheritance

jmh530 john.michael.hall at gmail.com
Wed Jun 17 17:23:35 UTC 2020


On Wednesday, 17 June 2020 at 16:01:29 UTC, Paul Backus wrote:
> [snip]
>
> IMO this can be done more elegantly by separating out the code 
> that looks up methods in the current module from the code that 
> does the actual type erasure.
>
> A while ago, I collaborated briefly with Adam Kowalski from the 
> Dlang discord server on some code to emulate C++-style 
> argument-dependent lookup in D. Using that code, your example 
> above would be written:
>
>     Geometry.create(r.extended).measure;
>     Geometry.create(c.extended).measure;
>
> Here's a gist with the code, along with a small example:
>
> https://gist.github.com/pbackus/0a70419eb8bece52f3a08edfe7b6019b
>
> If anyone thinks it's worthwhile, I can toss this up on Dub. 
> Personally, I've never had much use for it in my own projects.

The syntax there looks nice (wouldn't hurt to make it even 
nicer!).

Your moduleOf (and associated functions) looks like it shares 
similar functionality as some of what is in vtableImpl in poly.d 
(particularly importMixin).


More information about the Digitalmars-d-announce mailing list