Slicing AliasSeq-s
Shriramana Sharma via Digitalmars-d
digitalmars-d at puremagic.com
Mon Dec 21 01:06:08 PST 2015
http://dlang.org/spec/template.html#TemplateTupleParameter
Apart from the obvious need for changing the references to tuples to alias
sequences (for which I'm working on a PR), my question:
Both the above page and http://dlang.org/phobos/std_meta.html refer to
"slicing" alias sequences. In D slicing means just creating another
reference to the same memory as the sliced object.
Given that AliasSeq-s cannot be written to[*], it's not possible for me to
test whether it's actually sliced or a new AliasSeq with the same elements
is created. Otherwise I could do something like this:
alias A = [int, 2, symbol];
alias B = A[1 .. $];
alias C = A[0 .. $ - 1];
A[1] = 3; // not possible
static assert(B[0] == 3 && C[1] == 3);
So out of curiosity I'd like to know how this is implemented in the
compiler: as really a slice or a copy? (Posting this to D and not learn
since it relates to compiler internals.)
--
Shriramana Sharma, Penguin #395953
More information about the Digitalmars-d
mailing list