Sam S. via RT wrote: >Storing IterationEnd in an array or passing it to a &map, would certainly >qualify as "doing something other than the intended =:= check" to it, >so... just don't do those things.
Don't introspect? Don't metaprogram? >How do you intend for &map and &reduce to do a preliminary check to >make sure that no input element is IterationEnd, without iterating over >the input list? I imagine that the check would be performed by whatever puts values into the IterationEnd-delimited context, where they have come from something else. So normally this would be a check when *outputting* from an iterator, in its pull-one method. One can always check that the value being returned by pull-one isn't IterationEnd in the cases where one doesn't intend to return the sentinel to end the iteration. For example, a List knows how many elements it has, even if some of those elements are IterationEnd. The iterator returned by the List.iterator method transfers values from the counted context to the IterationEnd-delimited context, internally maintaining an index that it compares to the element count. (This happens in methods pull-one and reify-and-pull-one in the anonymous iterator class in List.iterator). That iterator code could check whether a value that it has retrieved by index is IterationEnd, and signal an error if it is. In the case of map, obviously it can't check its input values, because they're already in an IterationEnd-delimited context, coming from an iterator. But map can check its output: it can look at what the user-supplied iteration function returned, and signal an error if that's IterationEnd. -zefram