isExpressions -> isValuesSeq

Shriramana Sharma via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 11 22:41:11 PST 2015


This is w.r.t. http://dlang.org/phobos/std_traits.html#isExpressions:

I am trying the following code:

import std.stdio, std.meta, std.traits;
void main()
{
    alias a = AliasSeq!(1 + 2, "foo" == "goo");
    if (isExpressions!a) write("This AliasSeq contains expressions: ");
    foreach (v; a) { write(v.stringof, ", "); } writeln();
    writeln("This should be: ", (1 + 2).stringof, ", ", ("foo" == 
"goo").stringof);
}

The output is:

This AliasSeq contains expressions: 3, false, 
This should be: 1 + 2, "foo" == "goo"

Clearly, the AliasSeq is not able to store the expressions themselves since 
they are automatically evaluated at compile time. It stores only the values 
that the expressions evaluate to. Further, expressions which are not 
evaluable at compile time aren't permitted in the AliasSeq. (I tried it.) 
Thus the appropriate name would thus be isValuesSeq, no?

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d mailing list