From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 1D20A7ED26 for ; Mon, 28 May 2012 13:17:27 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApYBAFFew0/RVaC2kWdsb2JhbABEtTAIIgEBAQEJCwsHFAQjghcBAQEDARICLAEBNwEECwsLOyISAQUBHAYTIodaAQMGBZl5CQOKbYQuAQWEKQpADYlIBosDG4UklRqOFT2EAA X-IronPort-AV: E=Sophos;i="4.75,670,1330902000"; d="scan'208";a="160242359" Received: from mail-gh0-f182.google.com ([209.85.160.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 28 May 2012 13:17:26 +0200 Received: by ghbz22 with SMTP id z22so1708975ghb.27 for ; Mon, 28 May 2012 04:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=e0GWYCY24v112du3W4hyW78saQxAyGOdsIsIdVmokTI=; b=LWzwRh3gO917xF6Qe+vvy6o7vRaVCxGeHx3DwVUJMZIetzb1oc+t+jAEEduW3PKuqF yByIM28MFbDzsQqSd22G3oM6Cyi2wmuQNNIvw12bNcMWAWb0lUKK1KuctsweXc3k85t+ 4AMFGryNRaFCQMT6gtwjl1ISu8SqtaRFgHFl4k0QraRPABVEAulPIbwIAVndMKq5J91l FqFrHjP8B1KR7cxPdJLk1QM7YQbfIEvRzxhD+7Ml1FMfIEeZW/yyA8fIOoki8udWzwK4 KxpwI9vm7bpW2Xt1ri+5nup4L2T0PSsn8enJSmwWmGb1CUrJz2yVP4BS2WxdnvDoV78P 6mUQ== MIME-Version: 1.0 Received: by 10.236.115.196 with SMTP id e44mr7477989yhh.90.1338203845337; Mon, 28 May 2012 04:17:25 -0700 (PDT) Received: by 10.100.128.19 with HTTP; Mon, 28 May 2012 04:17:25 -0700 (PDT) In-Reply-To: <9B6D7FCED63545E2BB3F0DDD7B337AA1@erratique.ch> References: <4FC26FDD.9010407@gmail.com> <71FFF6A2CF1E4E6DA0FFF397B2084B89@erratique.ch> <9B6D7FCED63545E2BB3F0DDD7B337AA1@erratique.ch> Date: Mon, 28 May 2012 12:17:25 +0100 Message-ID: From: Wojciech Meyer To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: Hongbo Zhang , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Re: Syntax extensions without Camlp4 On Mon, May 28, 2012 at 10:35 AM, Daniel B=FCnzli wrote: > You meant 'typechecked' (?). It's obviously a generalization but I didn't= know there was support to use it at compile time. I meant with small amendments you can make MetaOCaml to work at compile time, one would need just special "force" construct to generate the code as usually at runtime but during compilation and assign the resulting code to the let bind. > >> The >> problem is that it's purely for partial evaluation and not extending the >> syntax. > > > Then it's perfect ! I think it's wrong to try to extend the language per = se. Most of the time, except for very particular things (e.g. introducing a= monad notation), the dsl approach is perfectly sufficient. Don't think you= absolutely need to extend the OCaml grammar, embed your dsl directly into = OCaml, using OCaml language binders if you need variables. I agree, that using combinators and run time meta programming you can do it without performance hit because you can partially evaluate your combinators. > > Make libraries, not pet syntactic constructs. Well, I agree and disagree at the same time. Some of the stuff can't be represented without extending the syntax. Introspecting types (type-conv) and generating code, bitstring matcher, monadic programming extension etc. there is a very fine grained line what can be done with combinators and what can't be. In particular, syntax extensions give the developer way to abstract things at the syntactic level, and they lift restriction that usual forms (like let, if, fun etc.) are not first class citizens. They also allow to change the evaulation order if it's needed. How much of this power is useful for daily programming - I don't know, but certainly having a better tool to the job would be great. It's just the existing tools make it ugly to use and degradate them to "pet syntactic constructs". > > Many things that can be done with camlp4, can be done with that approach.= Not only is it very elegant, it's much easier to maintain w.r.t. the evolu= tion of the OCaml language itself. The techniques in these papers [1] shoul= d be more known and used. Thanks for the links, certainly I will read them. > If you extend the grammar itself, code highlighters or any tool expecting= an OCaml expression is going to break whether the tool is external or not.= But for the rest of your comments I agree wholeheartedly (even though I'm = not sure all that power is needed, but at least it would make the tool non-= ugly to me). Of course you can, using the approach taken by Typerex server, the difference is of course that then Typerex does not need any build step, because the extension is self contained in the ML file. - Wojciech