From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: jon@ffconsultancy.com
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] "OCaml gives you only monomorphic methods in classes."
Date: Tue, 08 Jan 2008 11:30:31 +0900 (JST) [thread overview]
Message-ID: <20080108.113031.162099765.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <200712290711.34066.jon@ffconsultancy.com>
From: Jon Harrop <jon@ffconsultancy.com>
> I just read this quote and I do not understand what it means:
>
> "In particular, the Hindley/Milner style of type inference used in languages
> such as OCaml or Haskell is incompatible with lots of assumptions of OO
> languages. One incompatibility is with overloading. That's why OCaml does not
> let you write + for both integer and floating point addition. Another
> incompatibility is with higher order polymorphism. That's why OCaml gives you
> only monomorphic methods in classes." - Martin Odersky
>
> In what way must methods be monomorphic in OCaml classes?
They don't. With the restriction that the types of polymorphic
methods cannot be inferred. There is also another subtle
limitation, that object are only allowed to have regular
types. As a result, one cannot write a polymorphic map method in
ocaml, but this is possible in Java 2 or Scala.
> On Saturday 29 December 2007 06:30:48 brogoff wrote:
> > What's the date that quote was made?
>
> Yesterday, by the professor heading the group at Lausanne who are developing
> one of the most widely touted modern statically-typed functional programming
> languages (Scala).
>
> > It was probably made before polymorphic methods were added to OCaml from
> > OLabl.
>
> Looks like polymorphic methods have been in OCaml for 5 years now:
>
> http://caml.inria.fr/pub/ml-archives/caml-list/2002/07/0efd71474f4d41a39e4250aeddcf08e5.en.html
Actually, this is now close to 10 years if you include the OLabl
distribution... The original paper on adding semi-implicit first-class
polymorphism to HM was published in 1997.
I'm quite sure that Martin Odersky is aware of this. I would rather
interpret his quote as meaning that you have to extend HM in a
non-trivial way to allow this. He was co-author of two papers
about extending HM with first-class polymorphism ("putting type
annotations to work") and OO (the HM(X) framework), a long time
ago too. All these extensions (including the one used in ocaml) have
drawbacks, in particular they are either verbose or have bad error
messages, or both...
Anyway, you should not underestimate his contribution to this area of
work.
> This is really ossifying my impression that the Scala developers (let alone
> the community) are not aware of the current state-of-the-art in statically
> typed functional programming languages despite the fact that their sole
> purpose is to improve upon them.
>
> Unfortunately, this is rubbing off on the Scala community who keep publishing
> articles making silly claims like "Scala is the first impure functional
> programming language".
This is maybe not fully correct, but at least one can say that Scala
is "the most impure of functional languages" :-)
Cheers,
Jacques Garrigue
next prev parent reply other threads:[~2008-01-08 2:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-28 23:37 Jon Harrop
2007-12-28 23:55 ` [Caml-list] " Gordon Henriksen
2007-12-29 0:27 ` Jon Harrop
2007-12-29 1:19 ` Gordon Henriksen
2007-12-29 1:30 ` Jon Harrop
2007-12-31 14:02 ` Kuba Ober
2007-12-29 4:31 ` Dylan William Hardison
2007-12-29 7:09 ` Jon Harrop
2007-12-29 6:30 ` brogoff
2007-12-29 7:11 ` Jon Harrop
2007-12-29 16:57 ` brogoff
2008-01-08 2:30 ` Jacques Garrigue [this message]
2008-01-08 9:42 ` Jon Harrop
2008-01-08 13:45 ` Peng Zang
2008-01-08 17:29 ` brogoff
2008-01-08 21:25 ` Paolo Donadeo
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=20080108.113031.162099765.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/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