Extended Type Design.
Benji Smith
dlanguage at benjismith.net
Fri Mar 16 15:37:48 PDT 2007
Andrei Alexandrescu (See Website For Email) wrote:
> Benji Smith wrote:
>> Aha. In that case, what would you think of the declaration:
>>
>> super const int MY_CONSTANT = 6;
>>
>> Since a value type doesn't have any pointers, it wouldn't make any
>> sense to apply super-constness to it, right? Should that be a compiler
>> error?
>
> This should be a compiler error.
>
> Andrei
Cool. That's what I'd expect.
Maybe rather than "super const", you could use "ref const" or "const*"
or something that directly indicates that this form of constantness
applies to the pointers rather than the values. If you use "ref" as a
replacement for "inout", then the "ref" keyword would get some re-use.
Actually, though, I kind of like the idea of "const*"
// Create a constant pointer from a mutable pointer
const* int* myPointer = pMutableInt;
// Or maybe like this:
*const int* myPointer = pMutableInt;
What do you think of that? At least the asterisk provides a better clue
to the functionality of the construct than an exclamation point would.
--benji
More information about the Digitalmars-d
mailing list