On 01/19/2017 01:06 AM, Ali Çehreli wrote:
> In other words, D's string
> mixins are the same as C's macros.
I was testing you! :p I meant "NOT the same as". :p
Ali
On 01/19/2017 12:41 AM, Chris Katko wrote:
> 1 - Is there any way TO get the output 64,64?
You can mixin the entire statement. I used the ~ operator but you can
use format() or the return value of a function as well:
mixin("array_t!(" ~ sizer2D!() ~ ") case2;");
// ...
mixin("arra
On Thursday, 19 January 2017 at 08:41:53 UTC, Chris Katko wrote:
Thank you!
So:
1 - Is there any way TO get the output 64,64?
Would this work for you?
import std.meta;
alias sizer1D = AliasSeq!(64);
alias sizer2D = AliasSeq!(64,64);
array_t!sizer2D caseX;
array2_t!sizer1D caseY;
Thank you!
So:
1 - Is there any way TO get the output 64,64? It seems like being
able to get a comma out of a mixin is a useful feature.
2 - Is this very non-standard / unrecommended practice and
there's a much better way to do this?
For example, in my actual code, I have an enumerator:
e
On 01/19/2017 12:03 AM, Chris Katko wrote:
> template sizer2D() // no params here for simplicity
> {
> const char [] sizer2D = "64,64";
> }
> array_t!(mixin(sizer2D!())) case2; // FAILS (error below)
> Error: template instance array_t!64 does not match template declaration
> arr
Addendum:
Writing the following:
writeln(mixin(sizer2D!()));
simply dumps 64 to stdout.
What's going on here? Have I run into a compiler bug?
I've tried to narrow this down to the minimum code that exhibits
the problem.
When I use a mixin, to supply the parameters for a template, it
works with ONE argument, but NOT TWO.
template sizer2D() // no params here for simplicity
{
const char [] sizer2D = "64,64";