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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 4A595BC69 for ; Thu, 15 Nov 2007 07:23:32 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAACB0O0dA6bjqnmdsb2JhbACOfwEBAQEHAggRGIEP X-IronPort-AV: E=Sophos;i="4.21,419,1188770400"; d="scan'208";a="19322244" Received: from wr-out-0506.google.com ([64.233.184.234]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Nov 2007 07:23:31 +0100 Received: by wr-out-0506.google.com with SMTP id c49so394059wra for ; Wed, 14 Nov 2007 22:23:30 -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=ZBj/0eRSUzvnqOy48re/1grICeUbTOi0XCb4fRWf+LI=; b=kYCSDyC/8ZKSgX9iJANERIGCrhz7u/WtHrDW3zYQGJ0mj80QonZ74qW23DbJeecnuGRx4qJypwW6giYK21bE0hU0mdqaCLvhWabUTwngOFZ0qF6KIfWnn6tJ2c885XrZQqVbZWfRv0zFDbVp1PKZNc8hTnXzcSdeRuv44CGzSDs= 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=t5H135yxk3+nyynjUc34ud7T3l05Tvh40UMosD++GKsFoYKhKUflrymAmtk+z/5fx8JJtQ4qOfrdI2tg+gSLglo09NmIGJjqNO9KPTEx6m5WD0l2dgltzBsE0LPgEKD1U/4Cz/NRNbk9tm3otxptnC91yyk4SzUpECvJz0KM9wo= Received: by 10.70.21.4 with SMTP id 4mr596917wxu.1195107809732; Wed, 14 Nov 2007 22:23:29 -0800 (PST) Received: from ?192.168.0.7? ( [69.152.94.247]) by mx.google.com with ESMTPS id h18sm3783390wxd.2007.11.14.22.23.27 (version=SSLv3 cipher=RC4-MD5); Wed, 14 Nov 2007 22:23:28 -0800 (PST) Message-ID: <473BE5DD.2000000@gmail.com> Date: Thu, 15 Nov 2007 00:23:25 -0600 From: Edgar Friendly User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Jacques Garrigue Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Compiler feature - useful or not? References: <20071114075827.GA24058@yquem.inria.fr> <473B28DF.2050705@gmail.com> <20071115.091714.58364160.garrigue@math.nagoya-u.ac.jp> In-Reply-To: <20071115.091714.58364160.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; compiler:01 syntax:01 sig:01 val:01 struct:01 camlp:01 camlp:01 ocaml:01 ocaml:01 compiler:01 coercions:01 assertion:01 trivial:01 edgar:98 wrote:01 Jacques Garrigue wrote: > This syntax could be nice, but it is just syntactic sugar for > > module Private_row : sig > type row = private int > val new_row : int -> row > end = struct > type row = int > let new_row i = assert (i >= 0); i > end > include Private_row > Funny to define a module (hiding) just to include it (un-hiding). This pair usually comes to a no-op, but here it doesn't. > I'm sure camlp4 can do that. > It can. But camlp4 holds back real development of the OCaml Community by dividing the language into incompatible splinter dialects or forcing us to code in pure OCaml which has little sugar. > Direct compiler support couldn't give you more: > > * you cannot use a coercion to create a row: coercions are purely > type-level features, and cannot execute any code; we don't want to > change this. On the other hand coercing row to int could be made ok. > Good point. And I guess there's no better way to pack the creation assertion with the type than a module with a constructor function... > * the "constraint ..." part cannot appear in an interface, since > interfaces cannot contain expressions > Having interfaces contain arbitrary expressions... difficult. But I guess that we would have a 90% solution by reducing the problem from arbitrary constraints to simple range constraints. As long as it worked for ints, floats and chars, .... Still not trivial, though. Kila la heri, E.