caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: Enrico Tassi <enrico.tassi@inria.fr>
Cc: Mailing List OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] How to rename a record field
Date: Fri, 7 Sep 2018 08:34:59 +0900	[thread overview]
Message-ID: <6FB58BFB-B903-4B22-8F03-4124FB178F32@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <20180906141809.6m4vcwnsqqqbsack@gargamel>

On 2018/09/06 23:18, Enrico Tassi wrote:
> 
> On Thu, Sep 06, 2018 at 10:17:25PM +0900, Jacques Garrigue wrote:
>> Records being the dual of variants, all the arguments apply.
>> Namely, if the name is allowed to change, field access can no longer
>> be seen as the intuitive projection (by name rather than position, since
>> only name information is available in the source code).
>> Field name disambiguation works in the same way too.
> 
> Thanks. I see why in the general case this makes the source code
> ambiguous.
> 
>>> type old = { bad : int; stuff : bool }
>>> type t = old = { good : int; stuff : bool }
> 
> But in a case as simple as this one where names are either different
> or occur in the same position I believe there is no ambiguity.
> "stuff" would always resolve to position 2 while both
> "good" and "bad" to position 1.


Suppose that (maybe in another module) you have

   type u = old = {bad : int; good : bool }

Now, a piece of code containing

        x.good

could mean either (x : old).bad or (x : old).stuff, with x having a type
compatible with both t and u simultaneously.

Here it happens that int and bool being incompatible, a wrong interpretation
would probably cause an error somewhere, but this looks rather unpredictable.
Worse, in ocaml it is not always decidable whether two types might be equal
or not, so a definition time restriction could be hard to predict too.

Jacques Garrigue

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

  reply	other threads:[~2018-09-06 23:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 11:36 Enrico Tassi
2018-09-06 11:48 ` Gabriel Scherer
2018-09-06 13:03   ` Enrico Tassi
2018-09-06 13:17     ` Jacques Garrigue
2018-09-06 14:18       ` Enrico Tassi
2018-09-06 23:34         ` Jacques Garrigue [this message]
2018-09-06 16:20 ` Alain Frisch
2018-09-06 16:21   ` Alain Frisch
2018-09-06 23:45     ` Jacques Garrigue
2018-09-07  8:36       ` Alain Frisch
2018-09-07 10:13         ` Jacques Garrigue
2018-09-07 12:49           ` Alain Frisch

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=6FB58BFB-B903-4B22-8F03-4124FB178F32@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=enrico.tassi@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;
as well as URLs for NNTP newsgroup(s).