The Status of Const

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Aug 13 20:20:55 PDT 2010


On 08/13/2010 06:35 PM, Walter Bright wrote:
> Steven Schveighoffer wrote:
>> I like how it reads naturally. I think it's also syntactically
>> unambiguous. Walter, please give this one some attention, I'd love to
>> see this fixed.
>
> This was endlessly discussed maybe 3 years ago. I probably invested over
> a hundred hours in trying to make it work.
>
> It doesn't work.
>
> It wasn't the syntax. There were many syntaxes proposed. The type system
> loses its coherency with such a special case in it. Generic code has
> weird problems, type deduction gets strange, types lose their
> composability, etc.
>
> But there is a solution:
>
> const(Object)* o;
>
> Yes, under the hood it's 2 levels of indirection. But it works, it
> requires no special syntax, it is completely consistent with the rest of
> how the type system works, there are no corner holes in it, etc.

Actually this is an even better solution:

const(Scoped!Type)* o;

The only issue is that you need to know the static type... polymorphism 
doesn't work with pointers.


Andrei


More information about the Digitalmars-d mailing list