It's worse than I thought

Janice Caron caron800 at googlemail.com
Fri Nov 30 09:59:37 PST 2007


On 11/30/07, Craig Black <cblack at ara.com> wrote:
> > (4) let "const(C)&" be the syntax for making mutable references to
> > const classes.
>
> I don't think adding an amphersand makes it any more understandable.

If you think of the ampersand as meaning "reference to", in the same
way that asterisk means "pointer to", then it makes a lot of sense. I
did a long explanation of this on the other thread. Essentially, what
we're saying is that because the ampersand is outside the brackets,
then "reference to" isn't const.

We do need a way of expressing "mutable reference to const class",
though. If this isn't the right syntax, I'm sure we can come up with
another one.



> > (5) let "const x = y;" be syntactic sugar for "const(typeof(y)) x = y;"
>
> Sure.  We can't already do this?

My rule (5) was necessary because of my rule (1). Janice's rule (1)
would make "const x = y;" (which is currently legal, as you say)
illegal, so I introduced rule (5) to put it back.



More information about the Digitalmars-d mailing list