#copy and friends

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

#copy and friends

Schwab,Wilhelm K
copy
        "Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy. Copy is a template method in the sense of Design Patterns. So do not override it. Override shallowCopy instead. Pay attention that normally you should call postCopy of your superclass too."

        ^self shallowCopy postCopy



shallowCopy
        "Answer a copy of the receiver which shares the receiver's instance variables. It should never be overridden. I'm invoked from the copy template method. Subclasses that need to specialize the copy should specialize the postCopy hook method."


The references to #postCopy are probably valid, but the comments above can't both be correct.  Right??

Bill


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

Re: #copy and friends

Levente Uzonyi-2
On Sat, 25 Sep 2010, Schwab,Wilhelm K wrote:

> copy
> "Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy. Copy is a template method in the sense of Design Patterns. So do not override it. Override shallowCopy instead. Pay attention that normally you should call postCopy of your superclass too."

It should be: Override postCopy instead.


Levente

>
> ^self shallowCopy postCopy
>
>
>
> shallowCopy
> "Answer a copy of the receiver which shares the receiver's instance variables. It should never be overridden. I'm invoked from the copy template method. Subclasses that need to specialize the copy should specialize the postCopy hook method."
>
>
> The references to #postCopy are probably valid, but the comments above can't both be correct.  Right??
>
> Bill
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

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

Re: #copy and friends

Stéphane Ducasse
In reply to this post by Schwab,Wilhelm K
+ 1

http://code.google.com/p/pharo/issues/detail?id=3004

Stef

On Sep 26, 2010, at 2:21 AM, Levente Uzonyi wrote:

> On Sat, 25 Sep 2010, Schwab,Wilhelm K wrote:
>
>> copy
>> "Answer another instance just like the receiver. Subclasses typically override postCopy; they typically do not override shallowCopy. Copy is a template method in the sense of Design Patterns. So do not override it. Override shallowCopy instead. Pay attention that normally you should call postCopy of your superclass too."
>
> It should be: Override postCopy instead.
>
>
> Levente
>
>>
>> ^self shallowCopy postCopy
>>
>>
>>
>> shallowCopy
>> "Answer a copy of the receiver which shares the receiver's instance variables. It should never be overridden. I'm invoked from the copy template method. Subclasses that need to specialize the copy should specialize the postCopy hook method."
>>
>>
>> The references to #postCopy are probably valid, but the comments above can't both be correct.  Right??
>>
>> Bill
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


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