No subject
Wed May 23 23:23:08 CEST 2007
veryDeepCopy!
Rob
On Mon, Jun 9, 2008 at 11:45 AM, Stefan Schmiedl <s at xss.de> wrote:
> On Mon, 9 Jun 2008 07:35:21 -0400
> "Rob Rothwell" <r.j.rothwell at gmail.com> wrote:
>
> > Did you mean
>
> Sorry for not being clear and typing garbage. I wrote that mail
> before I had coffee...
>
> >
> > user1 :=3D RegistryUser new. (you never defined RegistryUser>>reg; if =
you
> > meant "registry", this would return a Registry)
> > user2 :=3D RegistryUser new.
> > user3 :=3D user1 copy.
> >
> > user1 =3D user2.
> > user2 =3D user3.
> > user1 =3D user3.
> > user1 =3D=3D user3.
> > user1 registry =3D user2 registry.
> > user1 registry =3D user3 registry.
> > user1 registry =3D=3D user3 registry.
> >
> > If this above is right, I would have expected user1 =3D user3, but I ge=
t
> false
> > (hmm...). However, user1 registry =3D user3 registry (which I would ha=
ve
> > expected), and user1 registry =3D=3D user3 registry, which I did not ex=
pect
> (?)!
>
> The "would have" and "did not expect" are my point.
>
> I'd guess in your Smalltalk
>
> RegistryUser>>=3D anObject
> ^ self =3D=3D anObject
>
> and since user1 and user3 are not the same object (only
> referencing the same target), they are considered not =3D.
> And the identity of the registries follows from that.
>
> I remember having a slight epiphany a while ago, when I realised
> that "variables" in Smalltalk do *not* contain anything, but
> *only* point towards objects piled up in the heap.
>
> With this "finger pointing" in mind, my setup comes down to the
> following narrative: user1 references an instance of
> RegistryUser containing a reference to an instance of Registry
> containing a reference to an instance of Dictionary.
> In short:
>
> user1 -> [registryUser#1](
> reg -> [registry#1](
> dict -> [dictionary#1]
> )
> )
>
> user2 is basically the same, only with a complete new set of
> objects:
>
> user2 -> [registryUser#2](
> reg -> [registry#2](
> dict -> [dictionary#2]
> )
> )
>
> Now, copy enters the stage. As shallow copy, it creates a new
> instance of its receiver's class, which in turn gets initialized
> with the instance variables *references* of the original:
>
> user3 -> [registryUser#3](
> reg -> [registry#1](
> dict -> [dictionary#1]
> )
> )
>
> so: user1 =3D user3 not,
> because [registryUser#1] =3D=3D [registryUser#3] not.
> However since for both users, reg -> [registry#1],
> the identity user1 registry =3D=3D user3 registry is explained.
>
> If you omit "immediate" values (like sufficiently small
> integers), objects are just containers for references to other
> objects, hence a shallow operation like copy only copies the
> structure, not the content.
>
> Time for a small test: Explain to yourself (or to the world at
> large), why I suggested "dict keys copy" instead of "dict copy
> keys" in your original mail.
>
> HTH,
> s.
>
> >
> > Rob
>
>
> --
> Stefan Schmiedl
> EDV-Beratung Schmiedl, Berghangstr. 5, D-93413 Cham
> im B=FCro: 09971 9966 989, am Handy: 0160 9981 6278
> _______________________________________________
> Aida mailing list
> Aida at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
>
------=_Part_19622_21858003.1213067770392
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
I really am reading this. And playing with it. Several times.&n=
bsp; I think this is important, and I will, indeed, explain at large when I=
get it, which I think I will.<br><br>From this maybe I will be able to go =
on and finally understand deepCopy and veryDeepCopy!<br>
<br>Rob<br><br><br><div class=3D"gmail_quote">On Mon, Jun 9, 2008 at 11:45 =
AM, Stefan Schmiedl <<a href=3D"mailto:s at xss.de">s at xss.de</a>> wrote:=
<br><blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(2=
04, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, 9 Jun 2008 07:35:21 -0400<br>
<div class=3D"Ih2E3d">"Rob Rothwell" <<a href=3D"mailto:r.j.ro=
thwell at gmail.com">r.j.rothwell at gmail.com</a>> wrote:<br>
<br>
</div>> Did you mean<br>
<br>
Sorry for not being clear and typing garbage. I wrote that mail<br>
before I had coffee...<br>
<div class=3D"Ih2E3d"><br>
><br>
> user1 :=3D RegistryUser new. (you never defined RegistryUser>=
>reg; if you<br>
> meant "registry", this would return a Registry)<br>
> user2 :=3D RegistryUser new.<br>
> user3 :=3D user1 copy.<br>
><br>
> user1 =3D user2.<br>
> user2 =3D user3.<br>
> user1 =3D user3.<br>
> user1 =3D=3D user3.<br>
> user1 registry =3D user2 registry.<br>
> user1 registry =3D user3 registry.<br>
> user1 registry =3D=3D user3 registry.<br>
><br>
> If this above is right, I would have expected user1 =3D user3, but I g=
et false<br>
> (hmm...). However, user1 registry =3D user3 registry (which I wo=
uld have<br>
> expected), and user1 registry =3D=3D user3 registry, which I did not e=
xpect (?)!<br>
<br>
</div>The "would have" and "did not expect" are my poin=
t.<br>
<br>
I'd guess in your Smalltalk<br>
<br>
RegistryUser>>=3D anObject<br>
^ self =3D=3D anObject<br>
<br>
and since user1 and user3 are not the same object (only<br>
referencing the same target), they are considered not =3D.<br>
And the identity of the registries follows from that.<br>
<br>
I remember having a slight epiphany a while ago, when I realised<br>
that "variables" in Smalltalk do *not* contain anything, but<br>
*only* point towards objects piled up in the heap.<br>
<br>
With this "finger pointing" in mind, my setup comes down to the<b=
r>
following narrative: user1 references an instance of<br>
RegistryUser containing a reference to an instance of Registry<br>
containing a reference to an instance of Dictionary.<br>
In short:<br>
<br>
user1 -> [registryUser#1](<br>
reg -> [registry#1](<br>
dict =
-> [dictionary#1]<br>
)<br>
)<br>
<br>
user2 is basically the same, only with a complete new set of<br>
objects:<br>
<br>
user2 -> [registryUser#2](<br>
reg -> [registry#2](<br>
dict =
-> [dictionary#2]<br>
)<br>
)<br>
<br>
Now, copy enters the stage. As shallow copy, it creates a new<br>
instance of its receiver's class, which in turn gets initialized<br>
with the instance variables *references* of the original:<br>
<br>
user3 -> [registryUser#3](<br>
reg -> [registry#1](<br>
dict =
-> [dictionary#1]<br>
)<br>
)<br>
<br>
so: user1 =3D user3 not,<br>
because [registryUser#1] =3D=3D [registryUser#3] not.<br>
However since for both users, reg -> [registry#1],<br>
the identity user1 registry =3D=3D user3 registry is explained.<br>
<br>
If you omit "immediate" values (like sufficiently small<br>
integers), objects are just containers for references to other<br>
objects, hence a shallow operation like copy only copies the<br>
structure, not the content.<br>
<br>
Time for a small test: Explain to yourself (or to the world at<br>
large), why I suggested "dict keys copy" instead of "dict co=
py<br>
keys" in your original mail.<br>
<br>
HTH,<br>
s.<br>
<br>
><br>
> Rob<br>
<font color=3D"#888888"><br>
<br>
--<br>
Stefan Schmiedl<br>
EDV-Beratung Schmiedl, Berghangstr. 5, D-93413 Cham<br>
im B=FCro: 09971 9966 989, am Handy: 0160 9981 6278<br>
</font><div><div></div><div class=3D"Wj3C7c">______________________________=
_________________<br>
Aida mailing list<br>
<a href=3D"mailto:Aida at aidaweb.si">Aida at aidaweb.si</a><br>
<a href=3D"http://lists.aidaweb.si/mailman/listinfo/aida" target=3D"_blank"=
>http://lists.aidaweb.si/mailman/listinfo/aida</a><br>
</div></div></blockquote></div><br>
------=_Part_19622_21858003.1213067770392--
More information about the Aida
mailing list