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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 542A3BC0A for ; Fri, 22 Dec 2006 03:03:39 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.191]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id kBM23cGZ027402 for ; Fri, 22 Dec 2006 03:03:39 +0100 Received: by nf-out-0910.google.com with SMTP id q29so3292437nfc for ; Thu, 21 Dec 2006 18:03:38 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=oS5WQcY3b/Nd9eKJ4JPEyjWuGVHlZdYR0u3kTpEtwDu9egQyC/X/lh5HmaptrHPSaw30yA5hXlI9+0j5inqeCDrtuR87uRyLzgUi5tHzLqQfFDWaVfvRAkcDHEhOcjrgS5vfbj3ViCrbjIUG2OJBH7OZg0Rbn5lN8CkD10sLucE= Received: by 10.82.118.2 with SMTP id q2mr60490buc.1166753018675; Thu, 21 Dec 2006 18:03:38 -0800 (PST) Received: by 10.82.153.16 with HTTP; Thu, 21 Dec 2006 18:03:38 -0800 (PST) Message-ID: <9d3ec8300612211803p58beac50t918080cb16faa37@mail.gmail.com> Date: Fri, 22 Dec 2006 03:03:38 +0100 From: "Till Varoquaux" To: "Peter Sewell" Subject: Re: [Caml-list] Re: Caml-list Digest, Vol 18, Issue 36 Cc: caml-list@yquem.inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20061221221725.5B539BC6F@yquem.inria.fr> X-j-chkmail-Score: MSGID : 458B3CFA.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 458B3CFA.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; runtime:01 runtime:01 marshaling:01 sockets:01 ocaml:01 pointer:01 ocaml:01 statically:01 type-safe:01 marshalling:01 gcaml:01 u-tokyo:01 furuse:01 gcaml:01 marshalling:01 On 12/22/06, Peter Sewell wrote: > > Philippe Wang wrote: > >Serge Aleynikov 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... > >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! > > If you want an upper bound on the cost of maintaining enough > information to calculate real type information at runtime, given > statically Caml-typable programs, you may like to look at the HashCaml > type-safe marshalling implementation > . We didn't > investigate performance in detail, and the code is not highly > optimized, but the cost certainly didn't seem to be outrageous. > > Peter > Gcaml (http://web.yl.is.s.u-tokyo.ac.jp/~furuse/gcaml/) also has types informations at runtime. It seems to be pretty close to what has been asked (ie simplicity of dynamically typed systems with security of statical types). I haven't played with it, so I don't exactly know what it does. However I do know it supposedly provides type safe marshalling, which gets me to ask: what is the main difference between marshalling in hashcaml and g'caml? Haskel's type classes also brings these kinds of features, I've been told they doesn't play nicely with the inference mechanism though... As for safeUnmarshal AFAIK tests for compatibility: it tests if the string can be unmarshall to a given type. However values of different types may be represented by the same marshalled string (correct me if I'm wrong). Till