On Wed, 7 Jan 2009, Jon Lang wrote:

I was just reading through S07, and it occurred to me that if one
wanted to, one could handle stacks and queues as iterators, rather
than by push/pop/shift/unshift of a list.  All you'd have to do would
be to create a stack or queue class with a private list attribute and
methods for reading from and writing to it.  The first two parts are
easy: "has @!list;" handles the first, and "method prefix:<=> { .pop
}" handles the second (well, mostly).

How would I define the method for writing to an iterator?

        Daniel (Ruoso) may be a better person to answer your query that I am.

I guess I'd assumed that writing to an iterator wouldn't be possible, as there are kinds of iterators where writing to them makes no sense; I'd assumed that if you wanted to write to something you'd use a list. Other than as an interesting exercise, I don't see the point of using an iterator for this purpose (there may *be* uses, but I don't see them).

        :)


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayl...@wayland.id.au    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Reply via email to