From: David Allsopp <dra-news@metastack.com>
To: Hendrik Tews <tews@os.inf.tu-dresden.de>,
"caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] What is an unsafe feature?
Date: Wed, 6 Mar 2013 10:36:13 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9CAFDA1E6@Remus.metastack.local> (raw)
In-Reply-To: <20791.5808.750356.139380@blau.inf.tu-dresden.de>
Hendrik Tews wrote:
> Hi,
>
> I always thought that the Obj module is unsafe and that functions
> containing "unsafe" in their name are unsafe too. However, when I run
> ocamlobjinfo on the .cmo of
>
> let f b =
> let a = "abcde" in
> let c = Obj.magic b in
> String.unsafe_blit c 0 a 0 5
>
> I see (with 3.12.1 and 4.00.1)
>
> Uses unsafe features: no
>
> So what is considered unsafe by ocamlobjinfo?
I think, looking at tools/objinfo.ml and tools/primreq.ml that this only refers to the compilation unit itself, not interfaces which it imports (try running ocamlobjinfo on stdlib.cma). The .cmo above simply imports Pervasives, String, Obj - the information that those are primitives is not recorded. If you changed it to:
external magic : 'a -> 'b = "%identity"
let f b =
let a = "abcde" in
let c = magic b in
String.unsafe_blit c 0 a 0 5
Then you will see the unsafe features warning from ocamlobjinfo.
David
prev parent reply other threads:[~2013-03-06 10:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-06 10:13 Hendrik Tews
2013-03-06 10:36 ` David Allsopp [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=E51C5B015DBD1348A1D85763337FB6D9CAFDA1E6@Remus.metastack.local \
--to=dra-news@metastack.com \
--cc=caml-list@inria.fr \
--cc=tews@os.inf.tu-dresden.de \
/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