Raoul Duke <rao...@gmail.com> writes:

> 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.
>
> i'm just trying to get my head around what it might look like, and
> if/how it might be useful. (it just bugs me that somebody can claim
> that C++ is the /only/ language that could do it -- maybe the real
> quote implied "mainstream" or something. apparently Ada wasn't up to
> snuff http://www.sgi.com/tech/stl/drdobbs-interview.html)

I don't know what are the Stepanov requirements, but C++ 
can do unboxed collections like  list<int>, which OCaml can
not provide I think. a 'int list' has boxed integers in OCaml. 

Also, a maybe good thing with STL is that you can write a single 'find'
or 'sort' function that will work for every kind of collections 
(list, arrays, map, hash, etc) by using the
indirect iterator idiom, without the penalty of dynamic dispatch
solutions. I am not sure OCaml can do that too.

The question is do we really need those 2 things ? 
I've worked a little bit with C++ using unboxed objects, that
is without introducing pointers (similar to boxing) in templates, 
like list<figure> instead of list<figure*>, and passing them
as value in parameters, or returning them, 
and it was far less efficient because there was lots of copy,
and you could not use then virtual method on them. So in the
end the C++ programmer I thing manually re-introduce boxing
when using STL if he wants good performance, and he can not really
rely either on the default copy/equal implementation provided
by those templates. So, yes STL makes it possible to do things,
but programmers don't want them, or only in very few cases where
one need extreme performance. 




>
> sincerely.
>
> _______________________________________________
> 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

_______________________________________________
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