2009/3/3 Raoul Duke <rao...@gmail.com>:
> hi,
>
> the caml archives show discussion around C++ polymorphism wrt STL
> (since Stepanov iirc said that C++ was the only language which
> supported what he needed to let him implement his generic programming)
> but i didn't yet see anywhere a concrete implementation or mapping
> from C++ STL to O'Caml.

As I recall, Stepanov did originally work containers in Lisp or
similar, but realized this would never help "real world" programmers.
The C++ template is far more powerful than originally anticipated and
Stepanov took advantage of that. Clearly, the choice of C++ has
affected the design of STL, so it would be pointless to try to port
STL directly to OCaml.

In fact, I think that OCamls basic Array, List, containers and
polymorphic algorithms does exactly what Stepanov intended to do,
without having to introduce Functors or other overhead. However, OCaml
could do with a more precisely defined container duck typing interface
(not an interface just convention) which I think will happen with
Batteries. I think perhaps OCaml could have a library of algorithms
that are not specific to one container type, but again that requires
better duck typed containers, and perhaps it is just better and more
efficient to implement the most important operations for each
container type instead of trying to generalized the entire world.

Scripting languages were not so hot at the time, short of Perl, but
Ruby would easily fit well into the STL idea, just like Lisp also did.

There was a discussion by STL insiders about wether algorithms (simple
example is the min function) should be template parameterized. They
ended up not having explicit type arguments because this was much
simpler to work with. Containers (like vector) have type arguments
because they were necessary in C++.

As to whether STL is well designed or not, fast or not, I think STL at
the time solved a great problem. Of course you could do something
faster, but often a map or set would be just what needed, just like
OCamls current Map and Set is usually good enough.

Mikkel

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to