From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 96499BC68 for ; Wed, 15 Nov 2006 00:12:33 +0100 (CET) Received: from mail-eur1.microsoft.com (mail-eur1.microsoft.com [213.199.128.139]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kAENCWTi016233 for ; Wed, 15 Nov 2006 00:12:33 +0100 Received: from EUR-MSG-11.europe.corp.microsoft.com ([65.53.193.197]) by mail-eur1.microsoft.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 14 Nov 2006 23:12:19 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] parameterized pattern Date: Tue, 14 Nov 2006 23:12:19 -0000 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [Caml-list] parameterized pattern Thread-Index: AccEHo3ESSNXL5X0Rx2ZiAPpvmxJOwEGzeqg From: "Don Syme" To: X-OriginalArrivalTime: 14 Nov 2006 23:12:19.0719 (UTC) FILETIME=[55698170:01C70842] X-Miltered: at discorde with ID 455A4D61.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; syme:01 syme:01 extensional:01 runtime:01 runtime:01 polymorphism:01 extensional:01 polymorphism:01 marshalling:01 debugging:01 matrices:01 matrices:01 iirc:01 fwiw:01 ocaml:01 > I just did a quick scan of some F# docs and=20 > I saw nothing. What did you have in mind? .NET type parameters are extensional, i.e. "you can always find out what 'a is at runtime". In particular in C# you can just write "typeof(T)", and in F# "(type 'a)", in each case getting a System.Type value. Supporting exact runtime types was a design decision we made in the early design stages for .NET generics.=20 As a result all .NET languages that support generics (polymorphism) have extensional polymorphism. It gets used heavily in the kind of meta-activities we're all familiar with: marshalling, pretty-printing, debugging (yes, Visual Studio 2005 shows you the values of "T", except when they've been optimized away). It also gets used internally in some libraries for adhoc optimization purposes, e.g. generating efficient comparison functions for default .NET comparers based on type arguments, and the F# matrix library uses it to detect when generic matrices are really floating point matrices, hence thunking out to more efficient matrix routines. =20 There are downsides to extensional polymorphism (e.g. you can wind up take up extra registers passing type parameters), but they don't seem to bite in practice. At the last ML Workshop a group at Cambridge University recently reported on an experiment to modify core-OCaml to pass runtime types, and IIRC saw no significant performance loss.=20 FWIW if you're interested I'd also like to mention the huge impact OCaml had on the design of .NET generics and C# 2.0, which I've never properly described on this list. It was seeing and experiencing polymorphic programming in OCaml and SML that made us persevere with the long and torturous process of convincing Microsoft that they should add such an "experimental and academic" feature as generics to their flagship runtime and languages. Of course we were in reality just making 1970s ideas work in practice, but at least now even Visual Basic has generics. Cheers, Don -----Original Message----- From: caml-list-bounces@yquem.inria.fr [mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of brogoff Sent: 09 November 2006 16:22 To: skaller Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] parameterized pattern On Thu, 9 Nov 2006, skaller wrote: > On Thu, 2006-11-09 at 05:19 +0000, Jon Harrop wrote: > > On Thursday 09 November 2006 01:45, brogoff wrote: > > > It's a pity, as I've often wished that OCaml supported the extensional > > > polymorphism that GCaml has, but I don't think that's going to happen. > > > It would probaby make more sense to create a separate language at this > > > point, since OCaml is complicated enough. > > > > I think F# provides some form of extensional polymorphism. I just did a quick scan of some F# docs and I saw nothing. What did you have in mind? > > I'm not convinced that it is a good idea yet... For almost any given language feature, there will be people who like it, and people who don't. Do you think having class based OO in OCaml is a good idea? I find it useful, especially since OCaml records are far too restrictive, but I hope that in some future ML that there are other approaches as the class/object system is complex, and the interactions with "core ML + modules" is tricky. That said, the class system is being used and it won't go away, and some people really like it. > Well FYI Felix has traditional (open) overloading, but since it > doesn't allow traditional C++ style dependent name lookup because > that would destroy parametricity of polymorphic functions, > something else was needed. > > So it now has first order typeclasses to solve this problem. Did you consider GCaml style generic functions? -- Brian _______________________________________________ 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