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 RAA01356; Thu, 4 Jul 2002 17:33:31 +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 RAA01398 for ; Thu, 4 Jul 2002 17:33:30 +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 g64FXSP17638 for ; Thu, 4 Jul 2002 17:33:28 +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 g64FXKSs000411; Fri, 5 Jul 2002 01:33:20 +1000 (EST) Received: from ozemail.com.au (ppp188.dyn1.pacific.net.au [61.8.1.188]) by wisma.pacific.net.au with ESMTP id BAA15570; Fri, 5 Jul 2002 01:33:17 +1000 (EST) Message-ID: <3D246ABC.9010306@ozemail.com.au> Date: Fri, 05 Jul 2002 01:33:16 +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: Alessandro Baretta CC: Oleg , Ocaml Subject: Re: [Caml-list] Re: generic programming References: <200207030246.WAA28665@dewberry.cc.columbia.edu> <4.3.2.7.2.20020703102610.0248b280@mail.d6.com> <200207032004.QAA07689@dewberry.cc.columbia.edu> <3D235FDE.6080203@baretta.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Alessandro Baretta wrote: > Templates are "nasty" citizens of the C++ world. I've had *so* many > problems tracking down bugs in code using STL templates. Basically, > the "write once, compile many" strategy of C++ yields situations where > the semantics of the algorithms coded in a template depends upon the > type parameter you pass to the template itself. Abominable. Well, it isn't that bad, but this: "the semantics of the algorithms coded in a template depends upon the type parameter you pass to the template" is entirely correct: instantiation is not functorial (it doesn't necessarily preserve the structure of the algorithm represented in the template .. alternatively, you can be 'nastier' and just say that a template algorithm doesn' *have* any semantics). FYI: as a member of the C++ committee I have fought long and hard to limit the damage by trying to insist that the type parameters of a template can only be bound to object types, and not 'const' or 'reference' types. If you allow such bindings, the semantics are wildly indeterminate. For example: template T f(T t) { return t; } f(x) // returns reference to x is utterly unlike f(x) // returns copy of x and one wonders what template T &( T &t) { return t; } means when instantiated like: f // what type is int && ?? Before you can have parametric polymorphism, you need a coherent type system .. :-) -- 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