caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: eizneckam@gmail.com, caml-list@inria.fr
Subject: Re: [Caml-list] syntax bug: copying records
Date: Wed, 21 Dec 2005 22:00:43 +1100	[thread overview]
Message-ID: <1135162843.8939.7.camel@rosella> (raw)
In-Reply-To: <20051221.194137.12318829.garrigue@math.nagoya-u.ac.jp>

On Wed, 2005-12-21 at 19:41 +0900, Jacques Garrigue wrote:
> From: Mackenzie Straight <eizneckam@gmail.com>
> > On 12/20/05, skaller <skaller@users.sourceforge.net> wrote:
> > > If x is a record then { x } should be a copy of it. But this
> > > doesn't work, I am using this ugly workaround instead:
> > >
> > > { x with dummy_field = x.dummy_field }
> > >
> > > Surely there is a better way?

> This also explains why you need at least one record field in the
> "with" notation, otherwise there is no way to know for sure the type
> of the record you're copying.

Why not?

If I write

	let x = expr in ...

then the type of x is determined by the type of expr unified
with the uses of x, right?

So the same inference doesn't apply to

	let x = { expr } in ..

instead, { .. } is required to have a definite type?
Couldn't this be checked instead, so that one could write:

	let x = { expr : thetype } in

which IMHO is preferable to picking one of the fields,
since the latter is fragile wrt the names of the fields.

How would you copy Lexing.lexbuf .. whose contents 
could be construed as implementation dependent?

Or worse .. a private record type .. which you *cannot*
copy with functional update .. although perhaps one could
argue if there is no copy constructor given it shouldn't
be copyable .. hmm.

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2005-12-21 11:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-21  5:22 skaller
2005-12-21  6:13 ` [Caml-list] " Mackenzie Straight
2005-12-21 10:41   ` Jacques Garrigue
2005-12-21 11:00     ` skaller [this message]
2005-12-21 18:07     ` Mackenzie Straight

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=1135162843.8939.7.camel@rosella \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=eizneckam@gmail.com \
    --cc=garrigue@math.nagoya-u.ac.jp \
    /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).