A better language

renox renosky at free.fr
Mon Apr 17 11:37:08 PDT 2006


Chris Nicholson-Sauls wrote:
[cut interesting remark showing that automagic pointer dereferencing 
reduce the interest of postfix pointer derefencing]
> // your idea: x: @[10]->int;
> // currently: int[10]* x;
> 
> Knowing that in D types are read right-to-left in declarations,

I know that and for me, this is an unpleasant pitfall of D, especially 
for array declaration:
int[Y][X] t; and then t[x][y] = ...

t: [X]->[Y]->int; and then t[x][y] = ...

Honnestly which reads better?

I know that D used to be (is still?) compatible with C declaration, but 
if helps for the array declaration (int t[X][Y];) but, this is a mess 
when there are pointers..

> I really 
> don't think we need this big of a change.  Especially since we do have 
> the 'function' keyword for doing function pointers.

I do agree that this is a big change and don't expect to see it in D, 
and in fact I'm so used to C's declaration that personnaly it's not a 
problem, but I do remember clearly that I had a hard time learning them 
while beginning C and I expect D beginners to have the same problem.. 
which is a pity.

Oh well, at least hopefully the out-of-bound exception will show them 
the mistake quicky (far from sure of course as it depends on the value 
used), but it is still a pitfall.

Regards,
renox

> 
> # void function (int, int) fn;
> #
> # void sumsqr (int dA, int dB) { return pow(dA + dB, 2); }
> #
> # fn = &sumsqr;
> 
>> Regards,
>> Renox
> 
> 
> -- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list