Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Anton Moscal <msk@post.tepkom.ru>
To: stephanh@win.tue.nl
Cc: caml-list@inria.fr
Subject: Re: Is this use of Object.magic safe?
Date: Wed, 15 Nov 2000 00:31:03 +0300 (MSK)	[thread overview]
Message-ID: <Pine.LNX.4.21.0011150027330.32539-100000@kouzdra.glokaya> (raw)
In-Reply-To: <00111310044001.28230@pcrm>

On Mon, 13 Nov 2000, Stephan Houben wrote:

> I have three questions:
> 1. Is this safe w.r.t. the garbage collector? Or am I going to confuse the GC?
> 2. Can I safely marshall values?
> 3. Is it worth the trouble? Perhaps O'Caml already does something smart
>    when a constructor of the form `Int of int' is encountered?

Answers for 1 & 2 is true,
for 3 - false: if you try to run the following program:

let _ = Printf.printf "%b\n" 
  (value_of_int 0 == value_of_allocated_value True)

you got "true" as the result.

The cause is the following: variant without arguments 
represented in the same way with int's.

Correct solution will be:

type allocated_value =
  Bool of bool 
| String of string 
| Array of value

Regards,
Anton Moscal 



  reply	other threads:[~2000-11-15 21:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-13  8:43 Stephan Houben
2000-11-14 21:31 ` Anton Moscal [this message]
2000-11-14 14:41 Damien Doligez

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=Pine.LNX.4.21.0011150027330.32539-100000@kouzdra.glokaya \
    --to=msk@post.tepkom.ru \
    --cc=caml-list@inria.fr \
    --cc=stephanh@win.tue.nl \
    /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