Herb Sutter briefly discusses D during interview

Trass3r un at known.com
Wed Jun 8 05:18:43 PDT 2011


Am 08.06.2011, 08:59 Uhr, schrieb Jonathan M Davis <jmdavisProg at gmx.com>:
> Left-to-right would end up being something more like this:
>
> a *int;
>
> or maybe
>
> *int a;

Yeah, like that improved anything. People who want the type to be to the  
right of the variable name should go use Pascal.

Really, one of the first things I read when I learned D was that  
declarations are read right-to-left and I immediately started to think  
that way. I'd even say it was intuitive to me.
It's consistent and fixes C's crappy behavior of splitting the type around  
the variable name.
And if you keep breaking down the type in your mind like "a is an array of  
3 elements being arrays of 5 ints" even the indexing discrepancy isn't a  
problem anymore.

Add qualifiers like const, maybe mix pointers, arrays etc. and C  
declarations become an even bigger mess while D ones are still consistent  
and easily readable cause of right-to-left.


A real problem might be the syntax for creating dynamic arrays:
auto arr = new int[][](4,5)


More information about the Digitalmars-d mailing list