Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christopher Jeris <cjeris@math.mit.edu>
To: Xavier Leroy <Xavier.Leroy@inria.fr>, caml-list@inria.fr
Subject: Re: anonymous record types in variants
Date: Wed, 17 Feb 1999 13:09:06 -0500 (EST)	[thread overview]
Message-ID: <Pine.SUN.4.03.9902171247250.28377-100000@severi.mit.edu> (raw)
In-Reply-To: <19990217103259.47130@pauillac.inria.fr>


On Wed, 17 Feb 1999, Xavier Leroy wrote:
> The reason why "{one : int}" is not a type expression but must be
> declared and bound to a type name have to do with type inference
> and the existence of principal types.  If you allow record types in
> type expressions (as in SML), some functions have no principal type,
> such as fun x -> x.l.

But an analogous construction already exists in the object system:

# let f x = x#foo;;
val f : < foo : 'a; .. > -> 'a = <fun>

And indeed I can replace records by objects in my first example:

  type foo = One of < one : int > | Two of < two : string >

But this doesn't solve the problem since (I think) I now have to name the
object type in order to create objects which belong to it.  So "open
record types" { one : int; .. } are just not a good idea ?

Another thing that kind of confuses me is open object types.  Can the open
object type < one : int; .. > be defined directly in any way ?

  type foo = < one : int; .. >

is rejected since .. is unspecified.  It seems that open object types can
result from inferences about the types of other objects/functions, but not
named directly ?  (Or am I trying to do the wrong thing ?)

Sorry if these questions are kind of elementary.  I'm still chewing on the
c/c0/c1/m example about 2/3 of the way through "Objects in Caml" :)

thanks & peace,

Chris Jeris	MIT Math grad student & novice OCaml music programmer




  reply	other threads:[~1999-02-17 18:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-12 20:53 Christopher Jeris
1999-02-16 10:57 ` Anton Moscal
1999-02-17  9:32 ` Xavier Leroy
1999-02-17 18:09   ` Christopher Jeris [this message]
1999-02-17 19:14     ` Didier Remy
1999-02-22  8:44   ` Anton Moscal
1999-02-22 13:00     ` Pierre Weis
1999-02-15 10:30 Don Syme
1999-02-15 18:03 Manuel Fahndrich
1999-02-16 17:40 Don Syme
1999-02-18 10:13 Frank A. Christoph
1999-02-18 14:03 Don Syme
1999-02-22 16:37 Manuel Fahndrich
1999-02-22 17:56 ` Pierre Weis

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=Pine.SUN.4.03.9902171247250.28377-100000@severi.mit.edu \
    --to=cjeris@math.mit.edu \
    --cc=Xavier.Leroy@inria.fr \
    --cc=caml-list@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