const(Object)ref is here!

Steven Schveighoffer schveiguy at yahoo.com
Wed Dec 8 12:38:07 PST 2010


On Wed, 08 Dec 2010 15:21:38 -0500, Michel Fortin  
<michel.fortin at michelf.com> wrote:

> On 2010-12-08 14:17:10 -0500, Walter Bright <newshound2 at digitalmars.com>  
> said:
>
>> I haven't been able to look at it yet.
>>  But the const system in dmd is rather complex, and I'm not at all  
>> comfortable with saying it works without quite a lot of testing. Some  
>> things to test:
>>  1. auto variable declarations
>> 2. typeof
>> 3. mangleof
>> 4. template type deduction
>> 5. interaction with inout
>> 6. arrays of, pointers to, functions returning
>> 7. tail const functions
>> 8. tail immutable
>> 9. tail shared const
>> 10. tail inout
>
> I've already tested most of this, but I'll make sure my unit tests cover  
> it all.
>
> That said, what's a "tail const function"?

it's not necessary to have a tail-const function for a class.  The only  
advantage of having a tail-const function would be if you wanted to change  
the 'this' pointer, which you shouldn't do anyways.

tail-const for a struct would then require tail-const functions (and would  
require being able to mark member functions to pass 'this' by value), but  
I don't think your patch addresses those.

Also note that inout doesn't really work at all, so I wouldn't bother  
testing anything with inout.

-Steve


More information about the Digitalmars-d mailing list