Article: Writing Julia style multiple dispatch code in D
Jean-Louis Leroy via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Aug 30 10:28:00 PDT 2017
On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer
wrote:
> One thing that confused me was examples like this ...
>
> @method
> Matrix _plus(DiagonalMatrix a, DiagonalMatrix b)
> {
> // just add the elements on diagonals
> // return a DiagonalMatrix
> }
>
> Which is marked as returning a DiagonalMatrix rather than a
> Matrix by polymorphism however the function is marked Matrix
> return type.
Indeed returning a DiagonalMatrix would work, and is marginally
more useful (in case you want to call the specialization
directly). I'll update the example. Thanks.
More information about the Digitalmars-d-announce
mailing list