On Wednesday, 25 May 2016 at 07:45:32 UTC, Jorge Lima wrote:
I can understand that array1 is not expanded to its value representation in the first call, but why is then when passed as an argument to the Constructor of the literal argument in the second call? Am I missing something obvious?
It is just the difference between an alias argument and an ordinary value use.
When passing a name to an alias argument, it retains its identity - `a` in there is now just another name for `array1`. When you `.stringof` it, it sees `a` is an alias for `array1` and pulls it instead.
I suspect you don't actually mean `.stringof` here... that gives the string representation of the identifier; it is what you see in the source (sort of), not the string of the value. `writeln(array)` would make it print out the value of the array.
Anyway, if you pass `a` to an ordinary function, like the struct constructor, it is then interpreted as a value instead of as a name of a variable and works the same way as the literal.
The difference is just on the outside, you aliased a name in one place and a literal in the other place, so that's why .stringof gave different results.