interesting return value

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

interesting return value

Jochen Riekhof
Hi...

I override postCopy  for the first time and find it very convenient,
although the comment says it is intended for special dependent release. Is
it good practise to use it for custom copying or should I better override
copy?

BTW:  when I just looked for implementations of postCopy, I noticed that,
while the Object>>postCopy uses the "interesting return value" pattern
^self, many subclass versions do not. I believe they should,  as
Object>>postCopy is called from Object>>copy as ^self  shallowCopy postCopy.

Ciao

...Jochen


Reply | Threaded
Open this post in threaded view
|

Re: interesting return value

Blair McGlashan
"Jochen Riekhof" <[hidden email]> wrote in message
news:[hidden email]...
> Hi...
>
> I override postCopy  for the first time and find it very convenient,
> although the comment says it is intended for special dependent release. Is
> it good practise to use it for custom copying or should I better override
> copy?

It is appropriate to override #postCopy if the copy is essentially a
modified shallow copy.

>
> BTW:  when I just looked for implementations of postCopy, I noticed that,
> while the Object>>postCopy uses the "interesting return value" pattern
> ^self, many subclass versions do not. I believe they should,  as
> Object>>postCopy is called from Object>>copy as ^self  shallowCopy
postCopy.

Yes, that's just lazyness. I'll add an enhancement request (#1415). It will
not appear in a patch though since it is cosmetic and affects quite a large
number of methods.

Regards

Blair