On Mon, 06 Oct 2003, Michal Moskal wrote: > On Mon, Oct 06, 2003 at 01:33:18PM +0200, Nicolas Cannasse wrote: > > Manipulating references is most of the time quite a pain, and make the code > > quite ugly. > > I understand in some cases the need of pure functional data structure (Coq > > code proof) but in the "average user" cases that target ExtLib, having a > > mutable structure is surely better. For example I often use an Hashtable > > where a Map would be better for theses two reasons : > > - no need to define a module type (this is corrected by this polymorphic > > version) > > - the hashtable is mutable ! means, easy to use. > > FWIW implementing mutable map on top of non-mutable one is easier and > more efficient then vice versa. Just need to use ref. Otherwise you need > to do some copy() tricks. I completely agree with Michal here: it's essentially impossible to get rid of the imperativeness of a datastructure unless you use some tricks like monads that hide the state. Probably not what the "average user" wants to work with :-) On Mon, 06 Oct 2003, Richard Jones wrote: > Hashtbls are much easier to use than Maps precisely for the reasons he > has outlined. They'd be even better if the language offered syntactic > support for them (but this just reflects my Perl background), eg: Note that you can always easily implement the functionality of Hashtbls using (purely functional) Maps and references - but not easily the other way round! See attachment for an implementation. I haven't tested the Hashtbl-code, but have used type annotations to have the code verified a bit more tightly. Furthermore, I have updated pMap.ml, because, as I have found out, its functional interface was incompatible with the on in Map and also lacked functions. On Mon, 06 Oct 2003, Claudio Sacerdoti Coen wrote: > Most of the time, mutable means non-reentrant. > This point should never be forgot when considering pros and cons > of an implementation. Expecially when dealing with proposed > "standard" libraries for a multi-threaded programming language. Which is another very good argument against impure structures that don't benefit from impurity in terms of efficiency... Regards, Markus -- Markus Mottl http://www.oefai.at/~markus markus@oefai.at