caml-list - the Caml user's mailing list
 help / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Enrico Tassi <enrico.tassi@inria.fr>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] How to rename a record field
Date: Thu, 6 Sep 2018 13:48:23 +0200
Message-ID: <CAPFanBFDMp3tABgk0aJn3SU5WYcxmspGcQ_Sc1OLcEnGQemKtQ@mail.gmail.com> (raw)
In-Reply-To: <20180906113622.lcuamhs6g6juv2r5@gargamel>

[-- Attachment #1: Type: text/plain, Size: 1740 bytes --]

A couple years ago I had a similar feature request for variant (sum)
constructors, and Jacques Garrigue explained that it is in fact quite
difficult. (The reasons apply to record fields as well.) I suspect that you
are out of luck.

  MPR#7102: Ability to re-export a variant definition with renamed
constructors?
  https://caml.inria.fr/mantis/view.php?id=7102


On Thu, Sep 6, 2018 at 1:36 PM Enrico Tassi <enrico.tassi@inria.fr> wrote:

> Dear caml-list, while refining an API I felt the need to rename a record
> field. I'd like to be nice to my users and have the API evolve without
> breaking compilation but eventually emitting deprecation warnings.
>
> What I'd like to do, concretely is to move from this
>
>   record t = { bad : int; stuff : ty }
>
> to
>
>   record old = { bad : int [@deprecated "use good"]; stuff : ty }
>   record t = old = { good : int; stuff : ty }
>
> The last line does not type check since old and good are different
> names. What I'd like to obtain is to have bad and good act as synonyms,
> and have OCaml generate a warning when bad is used.
>
> This is pretty much what you would do for a function: leave the old one
> in place and stick a deprecate attribute to it.
>
> Is there a way to achieve that for records?
>
> Best,
> --
> Enrico Tassi
>
> --
> 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
>

-- 
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

[-- Attachment #2: Type: text/html, Size: 2301 bytes --]

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06 11:36 Enrico Tassi
2018-09-06 11:40 ` Gabriel Scherer [this message]
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:35         ` Jacques Garrigue
2018-09-06 16:21 ` Alain Frisch
2018-09-06 16:21   ` Alain Frisch
2018-09-06 23:45     ` Jacques Garrigue
2018-09-07  8:37       ` Alain Frisch
2018-09-07 10:14         ` Jacques Garrigue
2018-09-07 12:50           ` Alain Frisch

Reply instructions:

You may reply publically 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=CAPFanBFDMp3tABgk0aJn3SU5WYcxmspGcQ_Sc1OLcEnGQemKtQ@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --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

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox