DConf 2013 Day 1 Talk 2 (Copy and Move Semantics)
Simen Kjaeraas
simen.kjaras at gmail.com
Sun May 12 03:59:29 PDT 2013
On 2013-05-12, 11:50, deadalnix wrote:
> On Sunday, 12 May 2013 at 09:10:56 UTC, Simen Kjaeraas wrote:
>> On 2013-05-12, 08:12, deadalnix wrote:
>>
>>> On Saturday, 11 May 2013 at 22:24:38 UTC, Simen Kjaeraas wrote:
>>>> I'm not convinced. unique, like const or immutable, is transitive. If
>>>> foo
>>>> is unique, then so is foo.bar.
>>>>
>>>
>>> That isn't true. Please read microsoft's paper.
>>
>> Done. *Mostly* transitive, then. Anything reachable through a unique
>> reference is either unique or immutable.
>
> No.
>
> Think about it : when you reach something via a uniq pointer, it is by
> definition not unique as you have 2 copies of it, because you just
> accessed it.
>
> Plus the unique pointer refers to a unique mutable graph of object. A
> object into that graph can have several object into the graph refereing
> to it.
>
> You are wrong in 2 different ways.
I'd argue it's only one way, if only to reduce the impact to my ego. :p
Yes, you're absolutely right. Anything reachable through a unique
reference needs to be *lent* or immutable. That way, it's either safe
to create new references to it, or the type system forbids it.
--
Simen
More information about the Digitalmars-d
mailing list