On Jan 4, 2011, at 11:43 PM, Ralph Boland wrote:
I earlier posted a Xmas wish that Pharo add generators (steal the generators code from Squeak). No one appeared to be familiar with them. The generators code was added to Squeak by Andreas Raas. The class Generator can be found in Squeak as a subclass of Stream. It's about 140 lines of code and, as I said before, is really useful and needed in order for me to port some of the packages I am developing from Squeak to Pharo. Class Generator is tested in class GeneratorTest which also serves as examples of uses of Generators. So please, someone go steal the code!
Ralph please package it, open ticket, so that we have tracability.
And stealing is easy.
We are not stealing we are reusing. And Generator are probably coming from GNU Smalltalk.
For example I stole the following comment on class Generator directly from the class comment:
" A Generator transforms callback interfaces into stream interfaces.
When a producer algorithm provide results as callbacks (blocks) and a consumer algorithm expects streamable input, a Generator transforms one into the other, for example:
| generator | generator := Generator on: [:g| Integer primesUpTo: 100 do:[:prime| g yield: prime]]. [generator atEnd] whileFalse:[Transcript show: generator next]. "
Regards,
Ralph Boland