We need to define the semantics of block initialization of arrays
Kenji Hara
k.hara.pg at gmail.com
Tue Jun 4 06:54:00 PDT 2013
2013/6/4 Don <turnyourkidsintocash at nospam.com>
>
> There is still one problem, bug 10198. This currently compiles, and does
> something stupid:
> ---
>
> struct U {
> int [3][3] y;
> }
>
> U u = U(4);
> ---
> What do you think should happen here?
>
Oh! I did not know it is currently accepted.
I think accepting multi-dimensional block initializing on StructLiteralExp
arguments is very bug-prone behavior.
Different from variable declaration in statement scope, there is no target
type we can look for. So inferring the cost of static array construction is
difficult.
struct U { int[3][3][3][3] w; }
U u = U(1); // looks trivial, but actually costly operation.
int[3][3][3][3] w = 1; // initializing cost is very obvious
At most it would be better that it is restricted up to one-dimensional
block initializing, same as StructInitializer.
Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130604/df07d28f/attachment-0001.html>
More information about the Digitalmars-d
mailing list