From: John S. <sk...@oz...> - 2003-06-21 03:52:44
|
The current Enum module seems inconsistent. The interplay between force, count, etc make the point in time at which user supplied next function is called indeterminate. That isn't really acceptable, since the enumeration is conceptually a model of a mutable object: even though the enum module itself is functional, it is being used to contruct mutator functions which operate on a stateful object. The fast_count function must be elided: it is a symptom of the designer not being able to make up his mind exactly what the model is. This is non-trivial. The only way to count a filtered enumeration is eagerly, on the other hand next can be applied lazily. In particular: it must be specified not only if count consumes an emumeration, but also if it forces lazy operations. Both questions must have a definite answer. The same is probably true for all other operations, however in most cases the answer is obvious. The point in time a next function supplied to make is called is of vital interest to the client and must be predictable due to side effects on the object being enumerated. There are several possible ways to resolve this issue, it is a nasty problem, but expected since the entity being modelled is stateful, and the client is providing mutators to the Enum module. The [from] function is the biggest hassle, I'd consider removing it. The client can always use init f limit which also might turn accidental infinite loops into merely very long ones :-) -- John Max Skaller, mailto:sk...@oz... snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 |