From: Nicolas C. <war...@fr...> - 2003-05-27 07:05:20
|
> You have two types (Enum and Stream) and a clear way to distinguish > them (whether count always makes sense). If you merge them, you push > the distinguishing feature to runtime. > > Also, it's not clear what the semantics of count on Stream are. Consider > Stream.of_list; does it do one traversal on creation to take the count? > Does it do it on the first call to count? What if it's on a List with > setcdr? Should count be treated as an expensive or an inexpensive op? > > I think it makes sense to create a stream from an enum, but the opposite > is not true. I think we are lucky count is there to remind us. If you > agree with this, then the two types should not be unified. I totally agree with you here. The only thing that should be mentionned, is that you can always use Enum instead of Stream, because it's better : - if the user doesn't need count, then it's better because he still can use all functionnal ops in Enum , as well as of_enum implementations in several data structures - if the user does need count, then Enum is providing the best way of doing it (that is : actually really "counting" elements, one by one) in an efficient way (see Enum.force) since only the first call to count will be costly. Nicolas Cannasse |