Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Mackenzie Straight <eizneckam@gmail.com>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: skaller@users.sourceforge.net, caml-list@inria.fr
Subject: Re: [Caml-list] syntax bug: copying records
Date: Wed, 21 Dec 2005 11:07:05 -0700	[thread overview]
Message-ID: <a7af81520512211007k48d83301w400272fb65808dbc@mail.gmail.com> (raw)
In-Reply-To: <20051221.194137.12318829.garrigue@math.nagoya-u.ac.jp>

On 12/21/05, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
>   # copy 3;;
>   Segmentation fault

I know. You can check the tag first if you really want. Like this:

let copy x =
  let r = Obj.repr x in
  if Obj.is_block r then
    Obj.obj (Obj.dup r)
  else
    x

Of course, we all know that using Obj is equivalent to using a dirty
syringe you found on the sidewalk, so... Danger!

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

True. Well, you don't actually need to know the type (indeed, the
runtime system needs to have enough information to copy values). But I
imagine it could have disastrous consequences when copying abstract
values anyway.


      parent reply	other threads:[~2005-12-21 18:07 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
2005-12-21 18:07     ` Mackenzie Straight [this message]

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