From: Brian H. <bri...@ql...> - 2003-04-16 19:15:18
|
On Wed, 16 Apr 2003, Nicolas Cannasse wrote: > If you look at enum.mli, there is NO WAY of doing a next() ! > Why ? because most of the time ( 99.99999% ) , you want to apply the same > algorithm to all the elements of your data structure, and I have the Java > while( e.hasMoreElements() ) { Object o = e.nextElement(); ... }. The "next" > function has to be implemented by the data structure, so the user won't know > about it, and the data structure of_enum implementation itself will have to > use most of the time Enum.fold/iter to fill itself. I was going to reply with a 'here is how you do it' code example- but having played with it you're right. The problem is dealing with an empty enumeration. You end up with a Some of/None problem. There is no nice way to implement the API I was advocating. You were right, and I withdraw the request. Brian |