cas and pointers

Stanislav Blinov stanislav.blinov at gmail.com
Mon Oct 31 19:37:25 PDT 2011


On 10/31/2011 10:13 PM, Michel Fortin wrote:
> On 2011-10-31 17:07:31 +0000, Sean Kelly <sean at invisibleduck.org> said:
>
>> writeThis really shouldn't be const, it should be shared. The problem
>> was t
>> hat making writeThis a shared pass by value param implied a
>> synchronized loa
>> d for writeThis, which is undesirable for cas. So I left the
>> declaration of c
>> as as specified in TDPL and thought I'd figure this out later.
>
> Perhaps it should be Unqual!(shared(V2)). That way if V2 is a pointer
> it'll be tail-shared.
>
> That won't work for class references though. For that you'd need my
> "const(Object)ref" patch rusting in DMD's pull requests.
>

Something tells me that currently this is unachievable without casting 
away shared on the caller side, which is kind of awkward. I mean, we can 
either have a signature that demands writeThis be shared (which it 
should be), but then we've got a synchronized parameter load, or a 
signature in which writeThis is not shared, which is (a) not safe and 
(b) would demand callers to cast away shared and implementation to cast 
it in again for an assignment...


More information about the Digitalmars-d mailing list