From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 901727ED27 for ; Mon, 28 May 2012 00:43:49 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AukBAPitwk9KfVK2kGdsb2JhbABFhTavWwgiAQEBAQkJDQcUBCOCFwEBAQMBEgIPHQEBNwEECwsLDwIFIQICDwEEIAEFASITIodaAQMGBQSZdAkDim1ug0ABBYNoCkANiUgGgSSODIESlRqBD40GPYQA X-IronPort-AV: E=Sophos;i="4.75,667,1330902000"; d="scan'208";a="160192631" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 28 May 2012 00:43:43 +0200 Received: by werg1 with SMTP id g1so2677315wer.27 for ; Sun, 27 May 2012 15:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=T84lEl0ez1THw/QtKkwuplDIyVEMOeWMZnoHAj/PqSY=; b=aCQpTlnTJMQpq15G7GkROqvjexUArqmJfbUXNMWgST+1CdjsiNmcCRWuIT/SJ7sJi9 3mkaA0qQO9knLmQSL/a8feIy9D4MqwOptMfmZMjFBKLD37LPefxvl5TNSrQ8sp/Z7r/p eJE9z5esnQDXndATBGEaaKSvyS8afOZnTYPp5MLSE1G8B91+CJ/y7KbY3vMxia743ZGA /qFoJlhcCGGhs+oD3WNoLqsJQ68MtY7pdDlrCs3nWGG5G1GZb60Ts1PV6rwafze5qeW+ ksFW0RlXXEc7qIPfusnPaBYiraEwBOBh0Y4CqjxPvHoYPTpImRRg2eHb717OS20ynNvf MPGA== Received: by 10.180.78.233 with SMTP id e9mr11073812wix.5.1338158622882; Sun, 27 May 2012 15:43:42 -0700 (PDT) Received: from spec-desktop.danmey.org (cpc1-cmbg12-0-0-cust201.5-4.cable.virginmedia.com. [86.9.116.202]) by mx.google.com with ESMTPS id k8sm26295130wia.6.2012.05.27.15.43.40 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 May 2012 15:43:41 -0700 (PDT) From: Wojciech Meyer To: Daniel =?utf-8?Q?B=C3=BCnzli?= Cc: Hongbo Zhang , caml-list@inria.fr References: <4FC26FDD.9010407@gmail.com> <71FFF6A2CF1E4E6DA0FFF397B2084B89@erratique.ch> Date: Sun, 27 May 2012 23:43:47 +0100 In-Reply-To: <71FFF6A2CF1E4E6DA0FFF397B2084B89@erratique.ch> ("Daniel \=\?utf-8\?Q\?B\=C3\=BCnzli\=22's\?\= message of "Sun, 27 May 2012 21:01:43 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Re: Syntax extensions without Camlp4 Daniel B=C3=BCnzli writes: >> I agree that it would be nice if we have metaocaml in. Agreed. > Why not. But metaocaml is not about static meta-programming, it provides = abstractions for runtime meta-programming. Runtime meta-programming is a generalisation of static meta programming. MetaOCaml has a nice set of abstraction to generate typechecking code - yes - either at runtime or during compile time. The problem is that it's purely for partial evaluation and not extending the syntax. Therefore the main purpose of syntactical abstraction is missing - but that's not a problem - MetaOCaml wasn't designed for it. Things that I would like to see in future "incarnation" or integrating of meta programming facilities to the language would be (beware that's my blue dreams!): - first of all non destructive updates to the grammar e.g: "let open lang Sexp in ..." should open the Sexp syntax extension, install the grammar, but when it goes out of scope it should vanish. Currently Camlp4 can install, delete the rules after the functor is applied, and no way of saying OK - let's go back. - Composable - in particular one language should behave like a module, or functor, should have an interface consisting of grammar rules, AST, AST transforms etc. So one could parametrise one syntax extension over another, and possibly reuse the language grammar or AST in other. Currently Camlp4 syntax extension is just a single separate module which when loaded possibly expects some existing grammar rules to be in place and mutates them as it's needed. - should be type safe and as mentioned before obey scoping rules. We should be able to propagate type information even when the syntax changes. This is difficult part - but I've seen it can be done with some extra annotations - not talking about Camlp4 - Recursive - it should be able to apply the grammar rules not only once but expand until it reached the fixpoint. - Reflective - it should be possible after each successful expansion have the type information available for the next expansion. - Grammar itself should be lexer-less - memoizing PEG with left recursion - it's hurdle to define new grammar in terms of old lexer, or having a stateful lexer that depends on context. - It should not be external tool - like previously observed - it's difficult to support for code highlighters or refactoring (tools in general) - if it depends on a build step or command line options. That's said I find Camlp4 extremely useful for code generation purposes - when I need to generate some ML code through quotations. Also, some very important projects depend on Camlp4 (or Camlp5) like Coq. I don't see that ML can live without some meta programming facilities out of the box. --=20 Wojciech Meyer http://danmey.org