Status: New
Owner: ----
New issue 3527 by rpboland: Please add the following Generator code to
Pharo. I need it to port a package I am writing from Squeak to Pharo
http://code.google.com/p/pharo/issues/detail?id=3527Squeak 4.1 has a class Generator which I use for a package I am developing
for Squeak and would also like to port to Pharo.
But Pharo doesn't have this class.
I propose that this class (and class GeneratorTest) be ported to Pharo.
I have attached the two .st files that need to be filed in.
I have loaded them into Pharo1.1 and it appears to work.
Note that since the code is in Squeak 4.1 it is MIT.
I have also signed the Pharo code release form though you would
really need the release form signed by Andreas Rass if that
is an issue.
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.
Class Generator is tested in class GeneratorTest which also serves
as examples of uses of Generators.
The following text is from the Generator 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].
"
Try it. You'll like it.
Regards,
Ralph Boland
Attachments:
GeneratorTest.st 4.7 KB