Extended Type Design.

Deewiant deewiant.doesnotlike.spam at gmail.com
Sat Mar 17 06:37:14 PDT 2007


Derek Parnell wrote:
> On Fri, 16 Mar 2007 15:54:26 -0700, Walter Bright wrote:
>> Derek Parnell wrote:
>>> Given ...
>>> 
>>> int[int**][]*[char[]][3][17][3,17]* x;
>>> 
>>> and I want to make the 'x' immutable and the 'char[]' immutable, how does
>>>  one write the declaration? Where does one place the 
>>> 'final'/'const'/'super const' and where do the parenthesis go?
>> final int[int**][]*[ const(char[]) ][3][17][3,17]* x;
> 
> Are you serious????
> 
> I want 'x' to be immutable so I need to use 'final' and place it the 
> furtherest away from what is is qualifying.
> 

Or you want it to be static:

static int[int**][]*[char[]][3][17][3,17]* x;

Or you want it to be private:

private int[int**][]*[char[]][3][17][3,17]* x;

Or deprecated:

deprecated int[int**][]*[char[]][3][17][3,17]* x;

In all cases, you place the attribute the furthest away from what it qualifies.
It's quite standard in C-family languages, including D, as I'm sure you know. I
don't see why "final"/"const"/"super const" should be any different.

> I want 'char[]' to be immutable so I must use 'const' and place it next to 
> what it is qualifying plus use parenthesis around its target too.

You need it within the same "scope" as the char[]: inside the [] where the
char[] is.

> Why do you think that this is intuitive, consistent, and easy to read?

What makes you think anything to do with a 35-character type is intuitive or
easy to read? ;-)

It's consistent enough for me.

-- 
Remove ".doesnotlike.spam" from the mail address.



More information about the Digitalmars-d mailing list