Extended Type Design.

Dave Dave_member at pathlink.com
Fri Mar 23 21:58:47 PDT 2007


Andrei Alexandrescu (See Website For Email) Wrote:
> Derek Parnell wrote:
> > On Fri, 16 Mar 2007 02:25:24 -0700, Andrei Alexandrescu (See Website For
> > Email) wrote:
> > 

<snip>

> 
> I was just trying to minimize the amount of broken code. Also, we 

<snip>

> 
> An intuition that I see reasonable is that const by default engulfs 
> everything to its right:
> 
> const char[] str = "Hi!"; // same as const(char[] str) = "Hi!";
> 
> When it engulfs the symbol, it makes it immutable, hence final. So by 
> putting the parens you limit const's power.
> 
> But I'd be glad to drop this exception. I'm not sure what Walter and 
> people who'll have to modify their code would say though.
> 

<snip>

> > 
> > The EXCEPTION (alarms still ringing)  seems to be saying that 'const char[]
> > X' means that X.ptr, X.length and the data in X's RAM cannot be changed.
> 
> I am hearing it. :o)
> 

Ok, this maybe somewhat selfish since I haven't used D's 'const' much, but I really have to agree with Derek -- the exceptions need to be dropped <g>

Based on past NG discussions on 'const', I believe it is so important to get this right the first time that the exceptions need to be removed in favor of the most intuitive and consistent syntax.

Since the current "const char[] str = 'XYZ'"; semantics would prevent both str or its elements from being modified, we could make a reasonable assumption that code already properly tested and running (and just recompiled with a new compiler) would not break anyhow, correct?

Thanks,

- Dave




More information about the Digitalmars-d mailing list