Idea to ease tail-const class reference woes

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 21 07:55:01 PDT 2008


"Janice Caron" wrote
> Oops. Typo. Let's try that again...
>
> Sounds more work than
>
>    import std.typecons;
>    Rebindable!(C) myClass = new C;
>
> which is planned for the future. (See D2.012 change log)

Cool, I didn't see that (understandably :) )

One thing that does sort of make me nervous is the added bloat to the type 
system for each type that I want to create a const class ref.  I count 3 
functions, which looks like there will be more when opImplicitCast is 
introduced, and the added TypeInfo.

We'll see how much it makes a difference when the implementation is 
finished.

Of course, I still prefer builtin tail-const class references, as no extra 
code bloat is necessary, no extra function calls (that do nothing but cast) 
are necessary, and everything just works in the most efficient manner 
possible.  But this is a workable solution.

Also, you're example should be:

Rebindable!(const(C)) myClass = new C;

-Steve 





More information about the Digitalmars-d mailing list