Trying to understand multidimensional arrays in D

Rekel paultjeadriaanse at gmail.com
Tue Dec 22 15:31:06 UTC 2020


On Tuesday, 22 December 2020 at 15:24:04 UTC, Rekel wrote:
> The way C syntax handles pointers isn't very consistent to 
> begin with imo.
> It's strange & and * are prepended to pointer variables for 
> example, while indexing is postpended. Leads to stuff like;
>> (*array_of_pointers_to_arrays[2])[1]
> vs
>> array_of_pointers_to_arrays[2]*[1]
>
> and
>
>> (*array_of_pointers[1]).x'
> vs
>> 'array_of_pointers[1]*.x'

Don't take that as a defence of changing pointer syntax by the 
way, just noting I think the argument pointers and arrays should 
be defined using a similar syntax is not consistent when thinking 
about indexing & dereferencing.

Besides, I think '[4]foo* foos;' is quite clear.
"array of foo pointers" seems very natural to me.


More information about the Digitalmars-d-learn mailing list