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.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id AE196BC69 for ; Fri, 16 Nov 2007 18:54:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAH5oPUfRVca7kmdsb2JhbACPDQEBAQEHBAQp X-IronPort-AV: E=Sophos;i="4.21,427,1188770400"; d="scan'208";a="19393863" Received: from rv-out-0910.google.com ([209.85.198.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Nov 2007 18:54:35 +0100 Received: by rv-out-0910.google.com with SMTP id k20so741046rvb for ; Fri, 16 Nov 2007 09:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=wj2ilZDAim+rnaDjrSDTU5W2bRoU9jlULzMOLnlO1CM=; b=gD9+D/rkxYzN9sI+RfAapyf1/aigjjyNiZm4klSrRPA2PlA4FoJpa8JU/5FF+Jw5P15Uuzazjq5d7DuUeAVNwP2IkALJCmqyBPH5Qopl6pBhbOAlxxa4/C7HYmA9psvXtMjZrU4K5HrvcQu0CLwlllz5GqPKZ/jRJQHIBkjJ26U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Yt40oICfvkX2DfterUsSYW36bsIsa+od9CyacUOLlGPbylNICS1Ztxw81C/V1LeZ7fFPQKW83Ic1ByV1lFi1usi8uhwa55vREyBr4wq+amPsXYOIkUcC6n4peDlgX6jxOoYNSTfTNLzMHiT/P2Jpo7YF339jrsE0y/8q+DwMh7o= Received: by 10.141.87.13 with SMTP id p13mr778765rvl.1195235674526; Fri, 16 Nov 2007 09:54:34 -0800 (PST) Received: from ?192.168.0.7? ( [69.152.94.247]) by mx.google.com with ESMTPS id i17sm4752865wxd.2007.11.16.09.54.32 (version=SSLv3 cipher=RC4-MD5); Fri, 16 Nov 2007 09:54:33 -0800 (PST) Message-ID: <473DD956.7090608@gmail.com> Date: Fri, 16 Nov 2007 11:54:30 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Martin Jambon Cc: Alain Frisch , caml-list Subject: Re: [Caml-list] Compiler feature - useful or not? References: <473A363F.2080301@gmail.com> <891bd3390711131608g48b584a4n6b0ccab95d7de3f3@mail.gmail.com> <20071114075827.GA24058@yquem.inria.fr> <473AEC04.3030303@frisch.fr> <20071114143524.GA4423@yquem.inria.fr> <473B249D.9040703@frisch.fr> <20071114184352.GB28796@yquem.inria.fr> <473BE750.9060301@frisch.fr> <20071115132649.GB15754@yquem.inria.fr> <891bd3390711151630x238b8eddod5b7462d0fa1c735@mail.gmail.com> <473D61A3.9090708@frisch.fr> <473DD301.90307@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; compiler:01 ocaml:01 polymorphism:01 casts:01 casts:01 runtime:01 runtime:01 edgar:98 2007,:98 edgar:98 wrote:01 wrote:01 caml-list:01 int:01 int:01 Martin Jambon wrote: > On Fri, 16 Nov 2007, Edgar Friendly wrote: > >> Martin Jambon wrote: >>> Please don't take my suggestions too seriously, but it could be cool to >>> define types such as: >>> >>> type bit = [ 0 | 1 ] >>> >>> >>> Martin >> >> How about this: >> >> type permission = >> User_read -> 0o400 | User_write -> 0o200 | User_execute -> 0o100 >> | Group_read -> 0o40 | Group_write -> 0o20 | Group_execute -> 0o10 >> | World_read -> 0o4 | World_write -> 0o2 | World_execute -> 0o1 >> >> let combine (pl: permission list) = >> List.fold_left (fun a b -> a lor (b :> int)) 0 pl > > I'm afraid of losing the following basic feature ("your first OCaml > program"): > > # 0;; > - : int > > and instead get: > > # 0;; > - : [< int > 0 ] > > Perhaps polymorphism should not be the default, i.e. we would have to > use a special keyword: > > # poly 0;; > - : [< int > 0 ] > # 0;; > - : int > Explicit casts, my friend. Explicit casts to convert from int to permission and back. And automatically generated runtime checks to ensure that you don't try to convert ( 37 :> permission ). 1 remains an int, and if you want World_execute (or true or anything else whose runtime representation is 1), a checked cast becomes necessary. E.