2010/1/12 Levente Uzonyi <[email protected]>: > On Tue, 12 Jan 2010, Bouraqadi Noury wrote: > >> Hi, >> >> I found the clone primitive method in the Object class. >> Its behavior looks the same as shallowCopy. Actually, shallowCopy just >> sends basicShallowCopy wich calls the same primitive as clone >> (primitive 148). >> > > I wonder what image do you use. In a standard image #clone is primitive > only, while #shallowCopy tries to copy the object if the primitive fails. > #basicShallowCopy doesn't exist. >
I am using #clone, to be 100% sure that i cloning object primitively, without additional logic, which #shallowCopy may introduce. > > Levente > >> a1 := Array with: Object new. >> a2 := a1 clone. >> a1 == a2. "--->false" >> a1 first == a2 first. "--->true" >> >> When I look to senders (in a pharo-dev 12.2) I find the following: >> -62 senders of clone. >> -2 senders of basicShallowCopy >> -66 senders of shallowCopy >> >> Looking to implementors I found: >> -9 implementors of shallowCopy (all are kernel classes) >> -1 implementor of basicShallowCopy (not surprizing) >> -6 implementors of clone (all are kernel classes) >> >> Most implementors of clone and shallowCopy are different. >> Yet, implementations done by same classes are the same behavior. >> Other implementations of clone answer self, because there are for >> objects that should/can't be copied (e.g. SmallInteger, Character). >> >> So, I suggest to remove clone and use shallowCopy instead (better/more >> precise name). >> Anybody has any reeason against? Otherwise, I'll do it. >> >> Noury >> >> >> >> >> >> _______________________________________________ >> Pharo-project mailing list >> [email protected] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [email protected] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Best regards, Igor Stasenko AKA sig. _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
