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.0 required=5.0 tests=none 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 34C58BC69 for ; Fri, 16 Nov 2007 18:31:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKJiPUc/0MSzb2dsb2JhbACPDQEJBQY X-IronPort-AV: E=Sophos;i="4.21,427,1188770400"; d="scan'208";a="19393229" Received: from mho-02-bos.mailhop.org ([63.208.196.179]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Nov 2007 18:31:09 +0100 Received: from gato.physics.und.nodak.edu ([134.129.186.227] helo=localhost) by mho-02-bos.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1It523-0009M7-0C; Fri, 16 Nov 2007 17:31:07 +0000 X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 134.129.186.227 X-Report-Abuse-To: abuse@dyndns.com (see http://www.mailhop.org/outbound/abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1/XPo8gpw+940eV/Wn48qQa Date: Fri, 16 Nov 2007 11:31:05 -0600 From: Fernando Alegre To: Martin Jambon Cc: Alain Frisch , caml-list Subject: Re: [Caml-list] Compiler feature - useful or not? Message-ID: <20071116173105.GA12079@gato.physics.und.nodak.edu> References: <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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Spam: no; 0.00; compiler:01 parametrized:01 compiler:01 camlp:01 compile-time:01 0100,:01 wrote:01 integer:01 caml-list:01 coercion:01 constraint:01 jambon:01 define:02 finite:02 finite:02 Even better would be to have a "parametrized finite" type. This would really need to be built into the compiler, as I don't think it can actually be emulated by either camlp4 or the C interface. The idea is very simple: add a primitive "n finite" type to the language, where n is a positive integer constant. For example: type bit = 2 finite type mod3 = 3 finite Then, fill the type by coercion so that "(x :> n finite)", where both x and n are known to be constant at compile-time and 0 <= x < n, becomes a value of type "n finite". This should be pretty straightforward to implement, and it may simplify code that depends on types such as "T1 | T2 | T3 | T4" I don't know how much it would be possible to relax the constraint above while maintaining the typesystem sound. Does anybody whether this is a known problem? Thanks, Fernando On Fri, Nov 16, 2007 at 05:43:39PM +0100, 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 ]