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.4 required=5.0 tests=AWL,HTML_MESSAGE 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 4A8E7BBAF for ; Tue, 24 Jun 2008 19:03:14 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhkEACvFYEjAXQImiGdsb2JhbACCPTWPOUMBAQEPIJoPhW8 X-IronPort-AV: E=Sophos;i="4.27,697,1204498800"; d="scan'208";a="26662586" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 24 Jun 2008 19:03:12 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m5OH3AYx025458 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 24 Jun 2008 19:03:11 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcBAGfFYEjRVcbkemdsb2JhbACCPTWPOUMBAQsDBAYHEZoPhW8 X-IronPort-AV: E=Sophos;i="4.27,697,1204498800"; d="scan'208";a="14487892" Received: from rv-out-0506.google.com ([209.85.198.228]) by mail3-smtp-sop.national.inria.fr with ESMTP; 24 Jun 2008 18:59:11 +0200 Received: by rv-out-0506.google.com with SMTP id k40so7949970rvb.57 for ; Tue, 24 Jun 2008 09:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to :to:subject:cc:in-reply-to:mime-version:content-type:references; bh=LhOHv08HFXY4tJPFp0tLqMWWCFrKIntDXeBO/3W3E0M=; b=NVSnu0x+mNMjX+99XFJE0v/sFdzHzldCUl89v17bX33sJqGCfJYPqvsz559TE+8Pjw nyY1gCLmxFonBJPeYI/KVKcBRoYqURRW3cv/0Zq1ewy43clJkfUAxH8G2OqBxrXf1jc8 q8EpUYPOpOwUiZ8s2elPY267HUjKjMYX6X6JE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to :mime-version:content-type:references; b=skZoO7/xGE+Iboxjol3fyVfK1KVYuUfAOgWBjVvR89mL0ns0sDjZgT+zJuBtpYaRnj XPAP00AdySMQ0koBlSlR+nGZzVZOFZ6+I93v3SOHo31b8ui2MPdWLzq7PtOhB07Jvwll FRV03UW7+y4KhW0Lw1Djk0HJxAiPpb5q4sffg= Received: by 10.141.13.13 with SMTP id q13mr10640989rvi.11.1214326740818; Tue, 24 Jun 2008 09:59:00 -0700 (PDT) Received: by 10.141.88.17 with HTTP; Tue, 24 Jun 2008 09:59:00 -0700 (PDT) Message-ID: <891bd3390806240959y1c8f75b2l83dc9c0317676d33@mail.gmail.com> Date: Tue, 24 Jun 2008 12:59:00 -0400 From: "Yaron Minsky" Reply-To: yminsky@gmail.com To: "Richard Jones" Subject: Re: [Caml-list] Custom lexer in Camlp4 Cc: "Jeremy Yallop" , caml-list@inria.fr, dan_mski@hotmail.com In-Reply-To: <20080624151626.GA8424@annexia.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_32542_1684403.1214326740818" References: <4860F097.1000701@ed.ac.uk> <1214317779-sup-8964@port-ext16.ensta.fr> <486104FF.1080201@ed.ac.uk> <20080624151626.GA8424@annexia.org> X-Miltered: at discorde with ID 486128CE.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; yaron:01 minsky:01 yminsky:01 lexer:01 camlp:01 0100,:01 camlp:01 literals:01 expr:01 expr:01 syntax:01 overloading:01 beginner's:01 ocaml:01 bug:01 ------=_Part_32542_1684403.1214326740818 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline You might want to take a look at an OSP project that is going on this summer that is aiming to implement something rather similar to what you describe: http://osp.janestcapital.com/files/delimited-overloading.pdf y On Tue, Jun 24, 2008 at 11:16 AM, Richard Jones wrote: > 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 > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ------=_Part_32542_1684403.1214326740818 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline You might want to take a look at an OSP project that is going on this summer that is aiming to implement something rather similar to what you describe:

http://osp.janestcapital.com/files/delimited-overloading.pdf

y

On Tue, Jun 24, 2008 at 11:16 AM, Richard Jones <rich@annexia.org> wrote:
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

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

------=_Part_32542_1684403.1214326740818--