Differing semantics between multidimensional fixed-length array and slice initialization

ixid nuaccount at gmail.com
Tue Apr 2 18:30:17 PDT 2013


On Monday, 1 April 2013 at 09:30:23 UTC, monarch_dodra wrote:
> 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.

How can you call the new syntax better? You assign arrays' 
lengths in the opposite to that that you access them. It's a 
horrible design mistake.


More information about the Digitalmars-d-learn mailing list