Differing semantics between multidimensional fixed-length array and slice initialization

monarch_dodra monarchdodra at gmail.com
Mon Apr 1 02:30:22 PDT 2013


On Monday, 1 April 2013 at 08:42:45 UTC, Nicholas Smith wrote:
> Ali, thanks for the justification. It makes enough sense, and 
> at least int[][](2, 3) matches the order in which you access 
> the elements.
>
> I agree with Bearophile though that the syntax is very messy 
> when you're mixing array types and pre/postfix declarations. If 
> you weren't shooting for C family syntax I'm sure array 
> declarations could be handled more gracefully.

I think the idea is that a "new" syntax was introduced, which, 
arguably, is better.

At the same time, the old syntax was kept, for compatibility.

Keeping both makes things complicated, and *mixing* both, well 
that's just evil.

IMO, it is a convenient and simple syntax if you decide to keep 
it that way. Just cause there are ways to make it complicated 
doesn't mean it's a good idea to do it that way.

Just keep things consistent with what you are doing: Use new 
style, and only new style in D code. Use old style (and only old 
style), when interfacing with a C-api, or if the code was ported 
from C.


More information about the Digitalmars-d-learn mailing list