Extended Type Design.
Andrei Alexandrescu (See Website For Email)
SeeWebsiteForEmail at erdani.org
Fri Mar 16 14:13:19 PDT 2007
Derek Parnell wrote:
> On Fri, 16 Mar 2007 11:02:39 -0700, Andrei Alexandrescu (See Website For
> Email) wrote:
>
>
>> void print(const char[] message); // not modifying message
>>
>> void main()
>> {
>> char[] myMessage = readln();
>> print(myMessage); // error! myMessage is changeable!
>> }
>>
>> I truly think we've distilled the simplest language within our requirements.
>
> Maybe the concepts but I'm not so sure about the usage.
>
> Given a function signature that has an array argument, there are two
> independant things we might want to remain unchangeable - the reference and
> the data referred to.
>
> To me, the signature ...
>
> void print(const char[] message)
>
> looks like 'const' is qualifying 'char[]' because that's what it is next
> to, and the 'message' looks like it is not qualified. So the signature
> looks like it is saying, the data is 'const' but the reference is not.
Exactly. All I'm saying is that if you go through the steps of your
system, you will see that it's unable to implement the notion of modular
mutability.
> Thus this below signature looks more like what you are trying to express
> ...
>
> void print(char[] const message)
>
> And to make both unchangeable then this looks better to me ...
>
> void print(const char[] const message)
We decided to use final to express symbol non-rebinding.
Andrei
More information about the Digitalmars-d
mailing list