tail const

Jonathan M Davis jmdavisProg at gmx.com
Wed Dec 1 10:15:12 PST 2010


On Wednesday, December 01, 2010 06:12:00 spir wrote:
> On Wed, 1 Dec 2010 03:17:24 -0800
> 
> Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > Various syntaxes have been proposed in the past. Syntax isn't really the
> > issue. It's pretty easy to come up with one. I think that out of the
> > ones I've seen,
> > 
> > the I liked the best was the one proposed by Michel Fortin:
> > >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
> 
> This is the nicest proposal, imo as well.
> Is "ref" used here only because "C * b" would mean double indirection?

* has nothing to do with references. * is for pointers. We're dealing with 
references here. C* would either be a pointer to a reference or a pointer to an 
object (I'm not sure which, technically-speaking, since it's a bit of a pain to 
deal with pointers and classes). Regardless, C* b already means something 
totally different.

- Jonathan M Davis


More information about the Digitalmars-d mailing list