From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=AWL,INFO_TLD autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id BCA23BC0A for ; Thu, 21 Dec 2006 22:27:30 +0100 (CET) Received: from 26.mail-out.ovh.net (26.mail-out.ovh.net [213.186.42.179]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id kBLLRU5u030080 for ; Thu, 21 Dec 2006 22:27:30 +0100 Received: (qmail 17054 invoked by uid 503); 21 Dec 2006 21:27:35 -0000 Received: (QMFILT: 1.0); 21 Dec 2006 21:27:35 -0000 Received: from b7.ovh.net (HELO mail146.ha.ovh.net) (213.186.33.57) by 26.mail-out.ovh.net with SMTP; 21 Dec 2006 21:27:35 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 21 Dec 2006 21:27:15 -0000 Received: from vil93-4-82-227-140-227.fbx.proxad.net (HELO ?192.168.1.2?) (lists%philippewang.info@82.227.140.227) by ns0.ovh.net with SMTP; 21 Dec 2006 21:27:12 -0000 Message-ID: <458AFC39.70707@philippewang.info> Date: Thu, 21 Dec 2006 22:27:21 +0100 From: Philippe Wang User-Agent: Thunderbird 1.5.0.9 (Macintosh/20061207) MIME-Version: 1.0 To: Serge Aleynikov , caml-list@inria.fr Subject: Re: [Caml-list] Scripting in ocaml References: <6dbd4d000612201941wcd4b09anc503a13889576512@mail.gmail.com> <20061221153413.8f99e8ed.mle+ocaml@mega-nerd.com> <1166685756.5337.4.camel@rosella.wigram> <458A8C7B.7050204@hq.idt.net> <1166709162.5653.11.camel@rosella.wigram> <458AA143.3090303@hq.idt.net> <20061221202520.GG9440@apotheon.com> <458AF864.20902@hq.idt.net> In-Reply-To: <458AF864.20902@hq.idt.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Remote: 82.227.140.227 (vil93-4-82-227-140-227.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Miltered: at concorde with ID 458AFC42.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 runtime:01 runtime:01 marshaling:01 sockets:01 ocaml:01 pointer:01 cheers:01 typing:01 integer:01 marshal:01 caml-list:01 lisp:01 unsafe:01 int:01 Serge Aleynikov a écrit : > 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... 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... If OCaml is particularly efficient, it's probably mostly because of that! ... Cheers, -- Philippe Wang mail(at)philippewang.info