[squeak-dev] Re: Rewriting 'ReadStream on: smth'

Paolo Bonzini bonzini at gnu.org
Thu Jun 5 08:07:46 UTC 2008


Damien Cassou wrote:
> Hi,
> 
> I'm interested in enhancing the code of Pharo (and maybe Squeak if the
> community is interested).
> Currently, I'm thinking about replacing 'ReadStream on: expr' by 'expr
> readStream'.

And #writeStream of course.

> I can see the following advantages of this change:
> 
> - no more direct reference on ReadStream where it is not necessary
> - allows different implementation of #readStream depending on the receiver class
> - clarify the code

+1.  In GNU Smalltalk I have added WriteStream>>#readStream and this not 
only adds polymorphism, it makes code faster by removing the copy made 
by #contents.

> Can you detect any problem with this approach?
> 
> The RefactoringBrowser allows this change to be done simply in all the
> method of the image.

If you're willing to review the changes by hand, you can more or less 
easily modify the Refactoring Browser's ParseTreeRewriter so that it 
prettyprints only the replacement text, not everything.  This solution 
would be pretty ad hoc; and as I said, I think it would require manual 
review.  But in my opinion it is worth the effort for this kind of 
refactoring.

Paolo



More information about the Squeak-dev mailing list