From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA07897; Mon, 8 Jul 2002 17:49:08 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA08323 for ; Mon, 8 Jul 2002 17:49:07 +0200 (MET DST) Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.25.148.40]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g68Fn4v01113; Mon, 8 Jul 2002 17:49:05 +0200 (MET DST) Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id g68Fn3Ss009731; Tue, 9 Jul 2002 01:49:03 +1000 (EST) Received: from ozemail.com.au (ppp229.dyn17.pacific.net.au [61.8.17.229]) by wisma.pacific.net.au with ESMTP id BAA18547; Tue, 9 Jul 2002 01:49:01 +1000 (EST) Message-ID: <3D29B46C.9080106@ozemail.com.au> Date: Tue, 09 Jul 2002 01:49:00 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: Francois.Pottier@inria.fr CC: caml-list@inria.fr Subject: Re: [Caml-list] Re: generic programming References: <4.3.2.7.2.20020703102610.0248b280@mail.d6.com> <200207030246.WAA28665@dewberry.cc.columbia.edu> <87r8il436y.fsf@ketanu.dyndns.org> <4.3.2.7.2.20020703102610.0248b280@mail.d6.com> <20020705103323.A14853@pauillac.inria.fr> <4.1.20020706000345.009f9610@pop3.btclick.com> <20020708115453.A32472@pauillac.inria.fr> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Francois Pottier wrote: >On Sat, Jul 06, 2002 at 12:05:30AM +0100, Dave Berry wrote: > >>>An iterator is a function that returns a function which maintains a >>>piece of internal state. >>> >>But can you compile it down to a single increment instruction on a pointer >>(for an iterator over an array)? >> > >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. > Simple: templates use 'textual substitution'. An array iterator IS a pointer. So there is no analysis to do. They're also good at optimising classes with a single data member (int, pointer, etc). The one that C++ compilers find hard is to see that the instantiations: copy ... copy can share the same implementation: programmers usually suppress code bloat on template instantiation using wrapping tricks, knowing that compilers aren't yet very smart at it. -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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