Article: Writing Julia style multiple dispatch code in D
data pulverizer via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Wed Aug 30 15:23:21 PDT 2017
On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy
wrote:
> On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer
> wrote:
>> In the light of this I think your package just became more
>> interesting to me.
>
> I think that your work and mine are complementary :-)
Yes, one of the problems I have been trying to solve is the best
way of writing a table structure similar to a data frame in R.
Till now polymorphism never really appealed to me but with your
package writing methods for such structures become much nicer, a
simple prototype could be this:
```
import std.stdio: writeln;
class GenericVector{}
class Vector(T): GenericVector{
T[] data;
this(T[] data)
{
this.data = data;
}
}
void main()
{
GenericVector[] myTable = [new Vector!double([1., 2., 3.]), new
Vector!string(["a", "b", "c"])];
writeln(typeid(myTable[0]));
writeln(typeid(myTable[1]));
}
```
Then your openmethods package can dispatch on these types of
objects. Very cool!
More information about the Digitalmars-d-announce
mailing list