Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Didier.Remy@inria.fr
To: John Prevost <prevost@maya.com>
Cc: caml-list@inria.fr, Kim Bruce <kim@bull.cs.williams.edu>
Subject: Re: Ocaml 2 object system origins
Date: Mon, 13 Sep 1999 15:15:57 +0200	[thread overview]
Message-ID: <19990913151557.26714@morgon.inria.fr> (raw)
In-Reply-To: <m33dws495j.fsf@isil.maya.com>; from John Prevost on Mon, Sep 06, 1999 at 06:38:32AM -0400

> I just came across the paper "Typing in object-oriented languages:
> Achieving expressiveness and safety" by Kim Bruce, and was struck,
> once I referred back to the O'Caml documentation on the new object
> system, by the similarities.
> 
> So, I was just wondering whether the features of the new object system
> are based on this paper, a predecessor of this paper, or perhaps the
> language LOOM, which apparently shares syntax with the examples in the
> paper.

Dear John,

Not at all. You might read [3,4] (the Ocaml home page lists those under
"Related papers"). In particular [4] provides theoretical foundations for
O'Caml objects and a very brief comparison with LOOM.

More precisely, the design of O'Caml finds its origins in some of my earliest
works on type inference for extensible records [1, etc] and especially in an
experimental prototype called MLART described in [3].

In MLART, objects were not primitive but encoded, and a small OO in a
library was provided.  The OO library of MLART was about as expressive as
the OO constructs of O'Caml. It included multiple inheritance, binary
methods, etc. , and of course full type inference.  However, the lack of
syntactic sugar for classes and of an abbreviation mechanism made both
object types and typing errors unreadable.

Hence, an essential part of the design of O'Caml is its sophisticated use and
propagation of automatic abbreviations to keep type expressions relatively
small.  O'Caml also cut down a little on the expressiveness of the class
language of MLART, so as to improve readability of both types and typing
errors.  The OO layer of O'Caml is formally described in [4] except for the
recent redesign of the class language, which is inspired by [5].

The type system of O'Caml entirely relies on ML polymorphism.  The only
insignificant difference with ML is that types are taken modulo an
equational theory, and hence do not form a free algebra.  On the other hand,
the language LOOM uses a new notion called matching (<#) and primitive
self-types. It is folklore (but I don't think it has ever been checked
formally) that matching does not accomplish more than polymorphism over
row-variables.  As a result of this correspondence, the core languages
of LOOM and O'Caml have similar expressiveness. In particular, they both
handle binary methods, correctly.

However, there are several situations where O'Caml does much better than
LOOM.  An important difference is that O'Caml uses structural types, and
treats the type of self (almost) as any other type (and therefore classes
can abstract over the type of self). On the contrary, the type of self is a
primitive notion in LOOM, called "Mytype".  Some advanced examples such as
virtual types (that can be naturally defined in O'Caml ---see for instance
the subject/observer example in the documentation and in [7]) cannot be
written in LOOM. (However, a recent extension of LOOM with a notion of group
has been introduced to solve virtual types [6].)

Also, LOOM does not have multiple inheritance, but this could be added quite
easily.  LOOM does not have type-inference, which is, of course a major
difference.

> (The presence of # types seems too much to be chance.)

As Jerome said, we choice the same symbol as the one used for hash-types in
LOOM because of the resemblance. However, O'Caml #-types are regular types
(this is just a notation for an implicit row-variable) while hash-types are
a primitive notion in LOOM.

Best regards,

        -Didier

----------------

See <http://cristal.inria.fr/~remy/publications.html> for details.

[1] Type Inference for Records in a Natural Extension of ML. 

[3] Programming Objects with ML-ART: An extension to ML with Abstract and
Record Types.

[4] Objective ML: An effective object-oriented extension to ML.  (with
Jérôme Vouillon).

[5] Using modules as classes by Jérôme Vouillon.
<http://cristal.inria.fr/~vouillon/publi.html>

[6] Semantics-Driven Language Design: Statically type-safe virtual types in
object-oriented languages by Kim B. Bruce and Joseph Vanderwaart.
<http://www.cs.williams.edu/~kim/README.html>

[7] The reality of virtual types for free! (with Jérôme Vouillon).




  parent reply	other threads:[~1999-09-14  7:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-06 10:38 John Prevost
1999-09-10 14:05 ` Jerome Vouillon
1999-09-13 13:15 ` Didier.Remy [this message]
1999-09-13 14:10   ` John Prevost
1999-09-13 21:43     ` Kim Bruce

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=19990913151557.26714@morgon.inria.fr \
    --to=didier.remy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=kim@bull.cs.williams.edu \
    --cc=prevost@maya.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