From: Nicolas C. <war...@fr...> - 2003-06-17 07:43:30
|
> > People keep saying that they can cut and paste the > > Functor based Set and Map to get a polymorphic version > > using the builtin-compare, so that: > > > > let s = ExtSet.empty in > > let s = Ext.set add_element s 0 > > > > for example, works (the type is deduced like for a list > > or Hashtble, rather than being manually instantiated.) > > > > Is there a plan to put these into Extlib? > > Another option would be > > > > let s = ExtSet.make cmp in .. > > > > where cmp is suitable comparator. > > What about: > > let s1 = ExtSet.make cmp1 in > let s2 = ExtSet.make cmp2 in > ... > let s = ExtSet.union s1 s2 Should raise something like "exception Comparator_differs" if not physical equality between s1.cmp and s2.cmp. in functor approach, you cannot actually do it since the comparator is bound to a type/module so errors are detected at compilation time and not at runtime. But that's a small tradeoff compared to the ability to define sets without having to define a module for every type you need. Nicolas Cannasse |