From: "Don Syme" <Don.Syme@microsoft.com>
To: <caml-list@yquem.inria.fr>
Subject: RE: [Caml-list] parameterized pattern
Date: Tue, 14 Nov 2006 23:12:19 -0000 [thread overview]
Message-ID: <D5DD834CDA73854DA0ADC8B3C953C681066F91A5@EUR-MSG-11.europe.corp.microsoft.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0611090757440.27097@shell2.speakeasy.net>
> I just did a quick scan of some F# docs and
> 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.
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.
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.
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
next prev parent reply other threads:[~2006-11-14 23:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-06 21:15 Serge Aleynikov
2006-11-06 23:58 ` [Caml-list] " Jon Harrop
2006-11-07 0:12 ` Serge Aleynikov
2006-11-06 23:59 ` Martin Jambon
2006-11-08 23:55 ` Lukasz Stafiniak
2006-11-09 1:45 ` brogoff
2006-11-09 5:19 ` Jon Harrop
2006-11-09 8:51 ` skaller
2006-11-09 16:22 ` brogoff
2006-11-09 17:55 ` skaller
2006-11-14 23:12 ` Don Syme [this message]
2006-11-15 1:00 ` brogoff
2006-11-15 1:36 ` Don Syme
2006-11-09 5:18 ` Jon Harrop
2006-11-09 16:42 ` micha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D5DD834CDA73854DA0ADC8B3C953C681066F91A5@EUR-MSG-11.europe.corp.microsoft.com \
--to=don.syme@microsoft.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox