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=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 0775ABBAF for ; Tue, 24 Jun 2008 17:16:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAAetYEjAXQIn/2dsb2JhbACyfA X-IronPort-AV: E=Sophos;i="4.27,696,1204498800"; d="scan'208";a="12477945" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Jun 2008 17:16:44 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m5OFGi8Q021217 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 24 Jun 2008 17:16:44 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAI+sYEhQRFuw/2dsb2JhbACzAA X-IronPort-AV: E=Sophos;i="4.27,696,1204498800"; d="scan'208";a="26658387" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Jun 2008 17:16:44 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1KBAFu-0002HL-82; Tue, 24 Jun 2008 16:16:26 +0100 Date: Tue, 24 Jun 2008 16:16:26 +0100 To: Jeremy Yallop Cc: Nicolas Pouillard , caml-list@inria.fr Subject: Re: [Caml-list] Custom lexer in Camlp4 Message-ID: <20080624151626.GA8424@annexia.org> References: <4860F097.1000701@ed.ac.uk> <1214317779-sup-8964@port-ext16.ensta.fr> <486104FF.1080201@ed.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <486104FF.1080201@ed.ac.uk> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at concorde with ID 48610FDC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexer:01 camlp:01 0100,:01 camlp:01 literals:01 expr:01 expr:01 syntax:01 overloading:01 persuade:98 sectors:98 wrote:01 integer:01 ints:01 caml-list:01 On Tue, Jun 24, 2008 at 03:30:23PM +0100, Jeremy Yallop wrote: > Ok, I've built a slightly modified clone of PreCast. What's the best > way to persuade Camlp4 to use it? The original PreCast seems fairly > hardwired, e.g. in the Register module. If you get an answer to this, please post it. I would love to be able to add new integer literals to the language (0UL and so on). On a related note I had a crazy brainwave that we could use camlp4 to use 'ordinary' operators in an overloaded context. Something like: INT64 (2L * n / 3L) The INT64(expr) macro would inspect the AST of expr and change + -> Int64.add etc. Of course one can do this using the pa_openin macro and a module which overrides (+) etc, but maybe this is better? I was going to try modifying parts of virt-df to use this syntax to see if it would be beneficial. After writing virt-df which uses mixed int64, int32, int and int63[*] types I'm starting to come around to Jon's opinion that some limited overloading or type classes or whatever would be worthwhile. Rich. [*] int63 is my own type: It turns into an efficient int on 64 bit platforms, and is emulated on (now rare) 32 bit platforms. It is necessary for virt-df because we want ints which can comfortably hold the size (in bytes / sectors / blocks / etc) of a block device. You don't really need a 64 bit int for this, but you do need something which is bigger than 32 bits. -- Richard Jones Red Hat