Article: Writing Julia style multiple dispatch code in D

jmh530 via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Aug 24 11:16:21 PDT 2017


On Thursday, 24 August 2017 at 16:10:32 UTC, data pulverizer 
wrote:
> Hi all,
>
> I have written an article about writing Julia style multiple 
> dispatch code in D 
> (https://github.com/dataPulverizer/dispatch-it-like-julia). I 
> am hoping that it is appropriate for the D blog.
>
> Reviews please.
>
> Many Thanks!

I think at one point I had actually suggested that dstats or 
something be re-written in a Julia-like way (before I realized 
how much work that would be!). It looks very pretty. 
Nevertheless, you might be re-inventing the wheel a bit if you 
want to build a whole library in this style. My recommendation 
would be to write a front-end for the dstats.distrib and 
dstats.random submodules in this style. That way you won't need 
to re-write all the functions, you can just call ones from dstats 
that have already been tested.

More generally, I prefer the structs because they don't rely on 
the garbage collector, but the class/interface version is 
prettier. Atila's concepts library has implements, which you 
might find helpful. I have gently nudged him to work on something 
that also can tell if a type is a subtype of another type more 
generally (like a struct being a subtype of another struct). I 
think this would really be a good use case for that functionality.



More information about the Digitalmars-d-announce mailing list