From: Pierre Weis <Pierre.Weis@inria.fr>
To: msk@post.tepkom.ru (Anton Moscal)
Cc: caml-list@inria.fr
Subject: Re: anonymous record types in variants
Date: Mon, 22 Feb 1999 14:00:54 +0100 (MET) [thread overview]
Message-ID: <199902221300.OAA07077@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.LNX.4.03.9902221137140.15888-100000@post.tepkom.ru> from "Anton Moscal" at Feb 22, 99 11:44:32 am
> But why? Natural semantic for anonymous types is the following: each
> anonymous record or algebraic types declaration introduces new type
> declaration in the current scope with some temporary type name. I.e.
>
> type ('a, 'b) foo = A of 'a * {l : 'b; l2: int}
>
> is a shortcut for:
>
> type ('a, 'b) temp_name = {l1 : 'b; l2: int}
> and ('a, 'b) foo = A of 'a * ('a, 'b) temp_name
>
> Regards,
> Anton Moscal
I proposed once (10 years ago ?) to have an ``as'' construct in data
type definitions: you could introduce a new datatype definition anywhere
in a datatype definition by writing
(type_definition_body as type_name)
with type_definition_body being one of the following:
[ | C1 {of t1} | C2 {of t2} | ...] for sum types
{ lab1 : t1; lab2 : t2; ... } for record types
type_expression for abbreviation types
the semantics you expect would then have been written as:
type ('a, 'b) foo = A of 'a * ({l : 'b; l2: int} as 'b temp_name)
This way the user could control the naming and number of type
arguments of the ``anonymous'' types defined, which is mandatory for
error messages from the typechecker, documentation purposes and clean
interfaces of modules.
As you mentioned it, such a scheme poses no problems at all to the
compiler, since it is just a shorthand for existing data type
definitions. On the other hand, it is conceivable to let the programmer
to expand this construct by hand, since it is just a few more lines to
write. That's the actual situation in the Caml light and Objective
Caml compilers.
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/
next prev parent reply other threads:[~1999-02-22 13:11 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
1999-02-17 19:14 ` Didier Remy
1999-02-22 8:44 ` Anton Moscal
1999-02-22 13:00 ` Pierre Weis [this message]
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=199902221300.OAA07077@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=msk@post.tepkom.ru \
/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