On 11/29/10 10:54 AM, Michel Fortin wrote:
On 2010-11-29 11:19:29 -0500, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:

Syntax is the main issue in implementing this feature. Due to the
implicit nature of reference semantics for classes, there was no
syntax to distinguish between the head and the tail when qualifying.

FWIW I just thought of this syntax. It might work but it's not intuitive:

const()C tailConst;

I proposed the following a while ago. First allow the class reference to
(optionally) be made explicit:

C a; // mutable reference to mutable class
C ref b; // mutable reference to mutable class

And now you can apply tail-const to it:

const(C)ref c; // mutable reference to const class
const(C ref) d; // const reference to const class
const(C) e; // const reference to const class

I think it's better.


Ultimately I believe we need to make Rebindable palatable. That would
have the nice side effect of enabling other proxy types.

The biggest problem I see is with generic programming. Say I pass
Rebindable!(const C) as a template argument, then the template wants to
make it const: should it become const(Rebindable!(const C)), or will
this be resolved to const(C)?

const should follow normal logic, and const(Rebindable!(const C)) should behave as expected.

Andrei

Reply via email to