Const Ideas (and reference types)

Jesse Phillips jessekphillips at gmail.com
Fri Nov 30 14:35:28 PST 2007


On Fri, 30 Nov 2007 15:27:20 -0600, Craig Black wrote:

>> So if you're going peel off the hidden ref, I think you might should
>> make it:
>>
>>     ref X x --> const ref(T) x;
>> or          --> const (T)ref x;
>> or          --> ref const(T) x;
>>
>> #3 seems pretty good to me.  But anyway no one knows what Walter will
>> decide to do.
> 
> Good point here.
> 
> Here's another idea.  If we reverse the meaning of const(X) then we
> could do this:
> 
> const X x;  // all const
> const(X) x; // data const, ref mutable X const x; // data mutable, ref
> const

On that note, we could try to keep Janice's idea that const X = const(X) 
and Adam's explanation of compile time function.

const X x; // data const
X const x; // ref const
const(X x); // both const

This would mean that const(T) takes a type T and returns a constant of 
it. Since in the last one, const(X x) takes a class and ref it will 
return a const of both. Equivalents of the above to help demonstrate the 
concept.

const(X) x; // data const
X const(x); // ref const
const(X) const(x); // both const



More information about the Digitalmars-d mailing list