Re: [stack] Generators revisited
"William Tanksley, Jr" <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Don Groves <[email protected]> wrote: > In rethinking the design of generators, it occurred to me that a > generator is in fact a closure. I'm not familiar enough with the > literature yet to know if closures already have an accepted > methodology in this group, so please enlighten me if this is so. Sure is! Actually, I kinda assumed that was going to be how you'd implement them :-). > A generator might look like [[f] a b ..] where f is the generation > function and a, b, etc, are its static data. A new combinator, > generate (as suggested by Billy), would be needed which would > disassemble the generator; apply f to the the list [a b ..]; > reassemble the generator; and push the new value on the stack. Yup. It's a simple enough function to define. The hard part is building all of the 'f's you might need. It's impossible to build them all; in general you have to let programmers build 'em for you. Icon takes one route (by making expressions be capable of repeating themselves); anyone know any others? > Don Groves -Billy