Re: [Pharo-project] Replacing 'ReadStream on smth:' by 'smth readStream'
Damien, Interesting! As an aside, I have a love/hate relationship with the RB, and almost never let it rewrite any of my Dolphin code. The XP guys will recoil in horror at this, but I have too often been saved by 18 month old comments to have them disrespectfully scattered around my source. If that is fixed, I will become a believer. I *do* use pull up/down to great advantage, and will sometimes use other refactorings on new code that has not had time to accumulate valuable comments. The above said, I have considered doing something like your rewrite to fix stream method naming snags. Consider #next. As we have discussed, I think it should be named #nextOrNil, allowing #next to behave as it does in Dolphin. Yes, I have a bias toward Dolphin, but I also consider its streams to be elegantly/correctly built. One way to fix it would be to transform #next into #nextOrNil (which is what Squeak's #next does), and then add a #next that signals EndOfStream on exhaustion; EndOfStream would have no default action in this scenario. If we could further transform any idioms such as aStream next ifNotNil:[ :x | ... ] into aStream nextIfPresent:[ :x | ... ] etc., that could be great if we did it well. Even a clean change to #nextOrNil would allow us to make an otherwise breaking change as painlessly as possible. FWIW, I have no direct problem with #on:, though I see where you are going. We might get a similar benefit by simply changing ReadStream in the system dictionary, making it an alias for NSReadStream?? Bill Wilhelm K. Schwab, Ph.D. University of Florida Department of Anesthesiology PO Box 100254 Gainesville, FL 32610-0254 Email: bschwab@anest.ufl.edu Tel: (352) 846-1285 FAX: (352) 392-7029
damien.cassou@gmail.com 05/30/08 4:47 AM >>> Hi,
I've just published in the pharo inbox a package for the System category. This change has been generated automatically through the rewriter: ParseTreeRewriter new replace: 'ReadStream on: ``@object' with: '``@object readStream'; yourself The formatting of the changed method is completely different due to the use of the refactoring browser. This makes the diffs not readable. Even if it is a real problem, I don't see any simple solution. What do you think? -- Damien Cassou Peter von der Ahé: «I'm beginning to see why Gilad wished us good luck». (http://blogs.sun.com/ahe/entry/override_snafu) _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
On Fri, May 30, 2008 at 2:13 PM, Bill Schwab <BSchwab@anest.ufl.edu> wrote:
The above said, I have considered doing something like your rewrite to fix stream method naming snags. Consider #next. As we have discussed, I think it should be named #nextOrNil, allowing #next to behave as it does in Dolphin. Yes, I have a bias toward Dolphin, but I also consider its streams to be elegantly/correctly built.
One way to fix it would be to transform #next into #nextOrNil (which is what Squeak's #next does), and then add a #next that signals EndOfStream on exhaustion;
I agree.
EndOfStream would have no default action in this scenario. If we could further transform any idioms such as
aStream next ifNotNil:[ :x | ... ]
into
aStream nextIfPresent:[ :x | ... ]
etc., that could be great if we did it well. Even a clean change to #nextOrNil would allow us to make an otherwise breaking change as painlessly as possible.
FWIW, I have no direct problem with #on:, though I see where you are going. We might get a similar benefit by simply changing ReadStream in the system dictionary, making it an alias for NSReadStream??
Even without talking about Nile, I think it is a good thing to avoid direct references to ReadStream. This also renders the code more readable. A third benefit is that #readStream could now be implement differently on different kind of streamable things. In Nile for example, String overrides #readStream to return an improved ReadStream for strings. -- Damien Cassou Peter von der Ahé: «I'm beginning to see why Gilad wished us good luck». (http://blogs.sun.com/ahe/entry/override_snafu)
On Fri, May 30, 2008 at 2:13 PM, Bill Schwab <BSchwab@anest.ufl.edu> wrote:
Interesting! As an aside, I have a love/hate relationship with the RB, and almost never let it rewrite any of my Dolphin code. The XP guys will recoil in horror at this, but I have too often been saved by 18 month old comments to have them disrespectfully scattered around my source. If that is fixed, I will become a believer. I *do* use pull up/down to great advantage, and will sometimes use other refactorings on new code that has not had time to accumulate valuable comments.
This problem has been fixed some time ago IIRC. -- Damien Cassou Peter von der Ahé: «I'm beginning to see why Gilad wished us good luck». (http://blogs.sun.com/ahe/entry/override_snafu)
participants (2)
-
Bill Schwab -
Damien Cassou