<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/07/d32dd70947be26ad7baf537ea0fb45f5"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T13:54:38"
  subject="Re: [Caml-list] Re: generic programming"
  prev="2002/07/e2cc2ea7d256e2884b0218dbe99e4f49"
  next="2002/07/eafbd035fc507a58c6fda5b07a8769f1"
  prev-in-thread="2002/07/dc781b0623ef875df91c3aafad01e44c"
  next-in-thread="2002/07/aad5a743288a064f4f5588efca0b71f5"
  prev-thread="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  next-thread="2002/07/b063648a2dd6d86053cf686570b2117e"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] generic programming">
<msg 
  url="2002/07/729263137a5c609a8795ff7b62ccf4d0"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-03T02:46:19"
  subject="[Caml-list] generic programming">
<msg 
  url="2002/07/086229a0f9b30e86a6556869bfe538ce"
  from="Johan Baltié &lt;johan.baltie@w...&gt;"
  author="Johan Baltié"
  date="2002-07-03T08:43:01"
  subject="Re: [Caml-list] generic programming">
<msg 
  url="2002/07/e2cc2ea7d256e2884b0218dbe99e4f49"
  from="Anton Moscal &lt;msk@m...&gt;"
  author="Anton Moscal"
  date="2002-07-05T13:28:26"
  subject="Re: [Caml-list] generic programming">
</msg>
</msg>
<msg 
  url="2002/07/dcbb97e00ea9ea5a3640e48d394074e9"
  from="Ketanu &lt;ketanu@w...&gt;"
  author="Ketanu"
  date="2002-07-03T08:43:22"
  subject="[Caml-list] Re: generic programming">
<msg 
  url="2002/07/81f12c5cad32eba3f02fcc732a0b0eb6"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-03T17:43:58"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/0314e671c829ee05f5aa5680605ecbd1"
  from="Oleg &lt;oleg_inconnu@m...&gt;"
  author="Oleg"
  date="2002-07-03T20:04:53"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/46e8a07b4366726933f941e9b77e5607"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-03T20:28:21"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/b0cf4d7882617fd27e03771a31589b70"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-04T15:33:31"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/b4d857a65ae262207463c99e98abb5f7"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-07T20:35:55"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/2702b480e76a128d5e149a4d57a81363"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-08T01:00:11"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/29380c5033d9738e56987cfd04cf7446"
  from="Alessandro Baretta &lt;alex@b...&gt;"
  author="Alessandro Baretta"
  date="2002-07-08T07:23:04"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/10/9771c361af322c3ddf2c05c7693bd197"
  from="Eray Ozkural &lt;erayo@c...&gt;"
  author="Eray Ozkural"
  date="2002-10-15T10:29:08"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/bc290463a2fb18079bf6f399c5a50e6f"
  from="Peter Wood &lt;peter.wood@w...&gt;"
  author="Peter Wood"
  date="2002-07-03T21:53:52"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/54c375615f0a29b27858964a3ea565a1"
  from="james woodyatt &lt;jhw@w...&gt;"
  author="james woodyatt"
  date="2002-07-04T02:02:06"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/f9169f3ec2d8758bc125264b2df6077c"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-04T15:18:38"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/9ef27ddc21bed28306035ffd3faf0846"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-05T08:42:51"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/fa6f4b49227ef840303e76915d7f82e0"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T09:25:54"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/dc781b0623ef875df91c3aafad01e44c"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-05T10:15:23"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/d32dd70947be26ad7baf537ea0fb45f5"
  from="Xavier Leroy &lt;xavier.leroy@i...&gt;"
  author="Xavier Leroy"
  date="2002-07-05T13:54:38"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/aad5a743288a064f4f5588efca0b71f5"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-07-05T18:18:33"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/6678e85245a3edc1fb95174cb4e3330c"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T20:31:27"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/7d4406847b9935e88eb5bb1f37218e5b"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T19:34:05"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
<msg 
  url="2002/07/3259c1827be396d71d70b2c7e2861447"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-05T19:31:26"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/00fb705ed9a16fca4d7ec6fcdd19a976"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-05T08:33:25"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/e5a3d181643111354651fc4afd3d96ab"
  from="Dave Berry &lt;daveb@t...&gt;"
  author="Dave Berry"
  date="2002-07-05T23:02:14"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/08/d395639496023bb4daa54d843df08749"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-08-02T14:52:44"
  subject="[Caml-list] Streams">
<msg 
  url="2002/08/929519264a1aa2fef08921548f609164"
  from="Alain Frisch &lt;frisch@c...&gt;"
  author="Alain Frisch"
  date="2002-08-02T15:29:07"
  subject="Re: [Caml-list] Streams">
<msg 
  url="2002/08/3ba1a139a7e1050e9b2233e0cc9eb5c2"
  from="Diego Olivier Fernandez Pons &lt;Diego-Olivier.FERNANDEZ-PONS@c...&gt;"
  author="Diego Olivier Fernandez Pons"
  date="2002-08-03T14:22:03"
  subject="Re: [Caml-list] Streams">
</msg>
</msg>
</msg>
<msg 
  url="2002/07/27f2e9a6fef12ae5f3dfeb79ca878644"
  from="Francois Pottier &lt;francois.pottier@i...&gt;"
  author="Francois Pottier"
  date="2002-07-08T09:54:55"
  subject="Re: [Caml-list] Re: generic programming">
<msg 
  url="2002/07/f49c4126b9e8f96224a3185f0b93557f"
  from="John Max Skaller &lt;skaller@o...&gt;"
  author="John Max Skaller"
  date="2002-07-08T15:49:08"
  subject="Re: [Caml-list] Re: generic programming">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2002/07/0f2535d349e6014a883b1f763837db62"
  from="Jun P.FURUSE &lt;Jun.Furuse@i...&gt;"
  author="Jun P.FURUSE"
  date="2002-07-03T09:10:27"
  subject="Re: [Caml-list] generic programming">
</msg>
</msg>
</thread>

<contents>
&gt; [Lots of interesting points about "push" vs. "pull" APIs omitted]

All you said is very reasonable, but I think you're generalizing the
discussion (especially with the GUI examples) beyond what I had in
mind, i.e. iteration over in-memory data structures.  In particular:

&gt; Giving up explicit control over the flow of your program is a 
&gt; serious problem in my opinion

When the task at hand is sufficiently abstract, e.g. "visit every
element of this set once", or "transform this list by applying this
function to each element", explicit control over the flow is something
that I'll gladly omit.  (Just like I'm happy not to have explicit
control over memory deallocation.)

In other terms, are you really saying that you prefer writing

        for (Enumeration e = l.elements(); e.hasMoreElements(); )
                frobnicate((SomeClass) e.nextElement());

over writing

        List.iter frobnicate l

&gt; It seems like it's something a good language should support well.
&gt; [...]
&gt; I wish Ocaml supported imperative/pull coding styles better, which
&gt; is why I'm interested in this thread.

The language provides full imperative power, and it's easy to write
imperative iterators over concrete data structure (like François
showed).  So, what more would you like?

True, abstract types provided by the standard library do not provide
imperative iterators (heavens forbid :-); but there are about three of
them (Set, Map, and Hashtbl), so I don't think this would really stop
you, should you embark in writing STL-style or java.util-style code in
OCaml...

&gt; Furthermore, it seems like it's a common trap to fall into saying the 
&gt; familiar "you don't want to do that" (like your comment about hashtables) 

My comment is more along the need of "I don't see when you'd ever need
to do that, but please enlighten me".  Say you have two hashtables;
please show me a situation where iterating in parallel over the two
hashtables (using two imperative iterators) would be more convenient
than what you can write with OCaml's current hashtable interface (only
functional iterators).

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

