From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Unsafe features
Date: Sat, 3 Sep 2005 12:19:42 +0100 [thread overview]
Message-ID: <200509031219.42582.jon@ffconsultancy.com> (raw)
In-Reply-To: <87y86elcb2.fsf@mid.deneb.enyo.de>
On Saturday 03 September 2005 10:40, Florian Weimer wrote:
> * Damien Bobillot:
> >> The C language interface falls into this category. Are there any
> >> other problematic areas?
> >
> > The Obj.magic function. I don't know exactly what it does, but I
> > think it does arbitrary type conversions.
>
> Apparently, it creates a bit-wise copy of a value and assigns it a new
> type.
>
> I discovered that there are also a couple of undocumented unsafe_*
> functions, such as String.unsafe_set, which behave the way their names
> imply (no bound schecks).
Yes, there is also the "-unsafe" command line option to turn off bounds
checking.
There is never any need to use Obj (although the alternatives can be quite
tedious or inefficient).
The marshalled format is likely to change between compiler versions in the
future so it should only be used for short-term storage anyway.
The C interface is very error prone and is (in general and IMHO) the most
likely cause of unsafeness. Programmers writing OCaml-only programs can
happily stick to the safe core of the language. However, programmers wishing
to use external libraries are likely to encounter problems. I have had
segfaults with code using LablGL and the FFTW bindings, for example.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
next prev parent reply other threads:[~2005-09-03 11:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-02 12:02 Florian Weimer
2005-09-03 9:24 ` [Caml-list] " Damien Bobillot
2005-09-03 9:40 ` Florian Weimer
2005-09-03 11:19 ` Jon Harrop [this message]
2005-09-03 12:07 ` yoann padioleau
2005-09-03 14:28 ` Florian Weimer
2005-09-03 14:35 ` yoann padioleau
2005-09-03 14:47 ` Florian Weimer
2005-09-03 14:51 ` Florian Weimer
2005-09-03 14:55 ` yoann padioleau
2005-09-04 1:58 ` Jacques Garrigue
2005-09-03 9:29 ` Erik de Castro Lopo
2005-11-29 18:46 ` Integral solutions of rational linear equations Thomas Gazagnaire
2005-11-30 8:32 ` [Caml-list] " Sebastian Egner
2005-11-30 8:49 ` Christophe Raffalli
2005-11-30 9:06 ` Christophe Raffalli
2005-11-30 9:08 ` Christophe Raffalli
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=200509031219.42582.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.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
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