Re: How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Nicholas Wilson via Digitalmars-d-learn

On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:

Z add(Z...)(Z a...) {
return a + b;
}

func[] operatorPool = [!int];

Variant library isn't liking that.  Removing & causes another 
error.


Essentially I want a pool of all operators that I define, but 
these operators can be of differing types (which I should be 
able to programatically grab), and different N-aryness.


Try using `variantArray` from std.variant. see 
https://dlang.org/phobos/std_variant.html#.variantArray


Re: How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Enjoys Math via Digitalmars-d-learn

On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote:

Z add(Z...)(Z a...) {
return a + b;
}

func[] operatorPool = [!int];

Variant library isn't liking that.  Removing & causes another 
error.


Essentially I want a pool of all operators that I define, but 
these operators can be of differing types (which I should be 
able to programatically grab), and different N-aryness.


func?  I mean std.variant.Variant there.


How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)

2017-01-17 Thread Enjoys Math via Digitalmars-d-learn

Z add(Z...)(Z a...) {
return a + b;
}

func[] operatorPool = [!int];

Variant library isn't liking that.  Removing & causes another 
error.


Essentially I want a pool of all operators that I define, but 
these operators can be of differing types (which I should be able 
to programatically grab), and different N-aryness.