Issue 4516 in pharo: copying a class should copy the sharedPools

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Status: Accepted
Owner: [hidden email]
Labels: Squeak

New issue 4516 by [hidden email]: copying a class should copy the  
sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

Otherwise, adding a new pool to the copy, will also add it to the original.
See





_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo

Comment #1 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.532.mcz

==================== Summary ====================

Name: Kernel-nice.532
Author: nice
Time: 29 December 2010, 10:59:42.464 am
UUID: 30e481ee-c2ee-4d10-8484-ec8da55ae54a
Ancestors: Kernel-ar.531

A] Clean-up Behavior and Metaclass copy by using postCopy paradigm.

Advantage 1:
This cleans up the false comment of Behavior>>copy (no, it does not copy  
without a list of subclasses).
This cleans up the false comment of Metaclass>>copy (no, it does share the  
reference to the sole instance).

Advantage 2:
The new code is shorter, simpler and avoids niling thisClass temporarily  
(this was dangerous).

B] Fix Class>>copy : the sharedPool shall not be shared
(if you #addSharedPool: to the copy and the original already has a  
sharedPool, then you #addSharedPool: to the original too...).
Move the comments "Answer a copy of the receiver without a list of  
subclasses." where it belongs, in Class>>copy.

=============== Diff against Kernel-ar.531 ===============

Item was removed:
- ----- Method: Behavior>>copy (in category 'copying') -----
- copy
-       "Answer a copy of the receiver without a list of subclasses."
-
-       | myCopy |
-       myCopy := self shallowCopy.
-       ^myCopy methodDictionary: self copyOfMethodDictionary!

Item was added:
+ ----- Method: Behavior>>postCopy (in category 'copying') -----
+ postCopy
+       super postCopy.
+       self methodDict: self methodDict copy!

Item was changed:
  ----- Method: Class>>copy (in category 'copying') -----
  copy
+       "Answer a copy of the receiver without a list of subclasses."
        | newClass |
        newClass := self class copy new
                superclass: superclass
                methodDict: self methodDict copy
                format: format
                name: name
                organization: self organization copy
                instVarNames: instanceVariables copy
                classPool: classPool copy
+               sharedPools: sharedPools copy.
-               sharedPools: sharedPools.
        Class instSize+1 to: self class instSize do:
                [:offset | newClass instVarAt: offset put: (self instVarAt:  
offset)].
        ^ newClass!

Item was removed:
- ----- Method: Metaclass>>copy (in category 'copying') -----
- copy
-       "Make a copy of the receiver without a list of subclasses. Share the
-       reference to the sole instance."
-
-       | copy t |
-       t := thisClass.
-       thisClass := nil.
-       copy := super copy.
-       thisClass := t.
-       ^copy!

Item was added:
+ ----- Method: Metaclass>>postCopy (in category 'copying') -----
+ postCopy
+       "Don't share the reference to the sole instance."
+
+       super postCopy.
+       thisClass := nil.!



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Updates:
        Labels: -Squeak Type-Squeak

Comment #2 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Updates:
        Labels: Milestone-1.4

Comment #3 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

Thanks!



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Updates:
        Status: FixedWaitingToBePharoed

Comment #4 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Updates:
        Status: FixProposed

Comment #5 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

See SLICE in inbox.
It also solves another problem: a copy of a Metaclass would share reference  
to the original class (inst. var. this pointing to the sole instance)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4516 in pharo: copying a class should copy the sharedPools

pharo
Updates:
        Status: Closed

Comment #6 on issue 4516 by [hidden email]: copying a class should  
copy the sharedPools
http://code.google.com/p/pharo/issues/detail?id=4516

in 14037
Thanks again


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker