From: Serge Aleynikov <serge@hq.idt.net>
To: Philippe Wang <lists@philippewang.info>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Scripting in ocaml
Date: Thu, 21 Dec 2006 17:06:24 -0500 [thread overview]
Message-ID: <458B0560.8090400@hq.idt.net> (raw)
In-Reply-To: <458AFC39.70707@philippewang.info>
Philippe Wang wrote:
>> What I meant by "strict typing" was performing type checks *at
>> runtime*, i.e. that there are no unsafe operations.
>>
>> Say, as an example, doing type checks of function arguments at runtime:
>>
>> let f = fun i when is_integer (i) -> i
>> | x when is_float (x) -> int_of_float x;;
>>
>> (raising Bad_match of some sort if neither one of the two guards pass)
>>
>> Direct application of this could be for making the Marshal/Unmarshal
>> modules more safe when marshaling data over files/sockets between
>> applications written in heterogeneous languages.
>
> If you want to do that, use Lisp...
Indeed. I am also quite happy with having that feature in Erlang. ;-)
> Or use sum types...
> type t = Int of int | Float of float | ...
>
> OCaml forgets types at runtime !
> This means that you can't know without a huge cost (cf. SafeUnmarshal
> costs), because what you can do in O(1) is to know whether a value is an
> int or a pointer...
There doesn't seem to be a large overhead for knowing if a value is a
closure, string, float or float array either (they have dedicated tag
values accessed with a single dereferencing). With having the compiler
reserve some tag values for other basic types that could optionally be
inspected at run-time, it perhaps wouldn't penalize efficiency very badly.
> If OCaml is particularly efficient, it's probably mostly because of that!
> ...
This thread began with John's statement that "interaction of the static
typing and dynamic loading was not easy". Any dynamic type check by all
means would reduce efficiency of a statically typed language. But maybe
it's possible to do dynamic type checking optional and make it available
if explicitly requested. At least if would make dynamic code loading
less complicated.
BR,
Serge
--
Serge Aleynikov
Routing R&D, IDT Telecom
Tel: +1 (973) 438-3436
Fax: +1 (973) 438-1464
next prev parent reply other threads:[~2006-12-21 22:06 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-21 3:41 Denis Bueno
2006-12-21 4:34 ` [Caml-list] " Erik de Castro Lopo
2006-12-21 7:22 ` skaller
2006-12-21 9:12 ` Till Varoquaux
2006-12-21 9:18 ` Chad Perrin
2006-12-21 10:29 ` skaller
2006-12-21 20:21 ` Chad Perrin
2006-12-21 13:30 ` Serge Aleynikov
2006-12-21 13:52 ` skaller
2006-12-21 14:59 ` Serge Aleynikov
2006-12-21 20:25 ` Chad Perrin
2006-12-21 20:41 ` Daniel Bünzli
2006-12-21 22:16 ` Chad Perrin
2006-12-22 12:21 ` strong/weak typing terminology (was Re: [Caml-list] Scripting in ocaml) Daniel Bünzli
2006-12-22 16:51 ` Tom
2006-12-22 17:34 ` Daniel Bünzli
2006-12-22 18:16 ` skaller
2006-12-22 18:47 ` Daniel Bünzli
2006-12-22 19:42 ` skaller
2006-12-22 20:03 ` David Brown
2006-12-22 20:17 ` Chad Perrin
2006-12-23 3:48 ` skaller
2006-12-23 4:11 ` Chad Perrin
2006-12-22 20:19 ` Chad Perrin
2006-12-23 12:58 ` Daniel Bünzli
2006-12-23 16:06 ` Chad Perrin
2006-12-23 21:50 ` Tom
2006-12-26 6:10 ` Chad Perrin
2006-12-22 20:14 ` Chad Perrin
2006-12-21 21:11 ` [Caml-list] Scripting in ocaml Serge Aleynikov
2006-12-21 21:27 ` Philippe Wang
2006-12-21 22:06 ` Serge Aleynikov [this message]
2006-12-22 12:35 ` Jon Harrop
2006-12-21 22:19 ` Chad Perrin
2006-12-22 12:37 ` Jon Harrop
2006-12-22 18:52 ` Chad Perrin
2006-12-22 2:51 ` skaller
2006-12-22 15:20 ` Jon Harrop
2006-12-22 11:32 ` Jon Harrop
2006-12-23 18:50 ` Jon Harrop
2006-12-24 0:15 ` Serge Aleynikov
2006-12-24 3:30 ` skaller
2006-12-21 14:59 ` Richard Jones
2006-12-21 20:27 ` Chad Perrin
2006-12-21 23:35 ` Martin Jambon
2006-12-26 17:14 ` Aleksey Nogin
2006-12-26 23:36 ` Ian Zimmerman
2006-12-27 18:25 ` Aleksey Nogin
2006-12-27 18:39 ` Richard Jones
2006-12-27 19:20 ` Aleksey Nogin
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=458B0560.8090400@hq.idt.net \
--to=serge@hq.idt.net \
--cc=caml-list@inria.fr \
--cc=lists@philippewang.info \
/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