<?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/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"
  prev="2002/07/29380c5033d9738e56987cfd04cf7446"
  next="2002/07/8d12ac2d99463ad68064b36be9eba6e9"
  prev-in-thread="2002/08/3ba1a139a7e1050e9b2233e0cc9eb5c2"
  next-in-thread="2002/07/f49c4126b9e8f96224a3185f0b93557f"
  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>
On Sat, Jul 06, 2002 at 12:05:30AM +0100, Dave Berry wrote:
&gt;
&gt; &gt;An iterator is a function that returns a function which maintains a
&gt; &gt;piece of internal state. 
&gt; 
&gt; But can you compile it down to a single increment instruction on a pointer
&gt; (for an iterator over an array)?

*In principle*, a compiler could perform closure analysis and determine
that the code pointer for the function `next' is known, so the closure
for `next' could be represented (in the case of an array iterator) as
a block containing a pointer to the array and a pointer to a reference
cell containing the current index. The code for the function could be
inlined and would consist in fetching both pieces of information, reading
the array and updating the reference cell.

*In principle*, a compiler could perform escape analysis and allocate the
reference cell on the stack, so accessing and updating it would be cheaper.

*In principle*, a compiler could perform must-alias analysis and find out
that the address of the array is already available elsewhere, thus obviating
the need to create a closure entirely.

Some ML compilers perform some of these optimizations. O'Caml performs none,
as far as I know; they are tricky to implement, especially in combination.
I'd be curious to see how C++ achieves this.

&gt; Also, can you compare two iterators for equality?

What is the semantics of such a comparison?

-- 
François Pottier
Francois.Pottier@inria.fr
http://pauillac.inria.fr/~fpottier/
-------------------
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>

