caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
Cc: Hongbo Zhang <bobzhang1988@gmail.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Re: Syntax extensions without Camlp4
Date: Mon, 28 May 2012 12:17:25 +0100	[thread overview]
Message-ID: <CAOg1smBbQe0Y8on=w=t76fTngQU6T6CZAGwpqRGh_peyxaBA-A@mail.gmail.com> (raw)
In-Reply-To: <9B6D7FCED63545E2BB3F0DDD7B337AA1@erratique.ch>

On Mon, May 28, 2012 at 10:35 AM, Daniel Bünzli
<daniel.buenzli@erratique.ch> 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 evolution of the OCaml language itself. The techniques in these papers [1] should 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

  parent reply	other threads:[~2012-05-28 11:17 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-27 15:06 [Caml-list] " Alexandre Pilkiewicz
2012-05-27 16:53 ` [Caml-list] " Hongbo Zhang
2012-05-27 18:04   ` Daniel Bünzli
2012-05-27 18:18     ` Hongbo Zhang
2012-05-27 19:01       ` Daniel Bünzli
2012-05-27 22:43         ` Wojciech Meyer
2012-05-28  9:35           ` Daniel Bünzli
2012-05-28  9:59             ` Gabriel Scherer
2012-05-30 14:45               ` Hongbo Zhang
2012-05-28 11:17             ` Wojciech Meyer [this message]
2012-05-28 15:52             ` Jeffrey Scofield
2012-05-27 18:19     ` Hongbo Zhang
2012-05-28  8:17     ` Paolo Donadeo
2012-05-30 12:41   ` Alain Frisch
2012-05-30 13:18     ` Markus Mottl
2012-05-30 13:37     ` Dan Bensen
2012-05-30 14:16       ` Hongbo Zhang
2012-05-30 14:23         ` Paolo Donadeo
     [not found]           ` <20120531081913.GA26742@securactive.lan>
2012-05-31 12:26             ` Paolo Donadeo
2012-05-31 12:38               ` Anil Madhavapeddy
2012-05-31 12:40                 ` Anil Madhavapeddy
2012-05-31 12:46                   ` Yaron Minsky
2012-05-31 12:47                   ` Gabriel Scherer
2012-05-31 22:08                 ` Paolo Donadeo
2012-05-30 14:14     ` Hongbo Zhang
2012-05-31 12:59       ` Alain Frisch
2012-05-31 13:21         ` Dmitry Grebeniuk
2012-05-31 14:30           ` Daniel Bünzli
2012-05-31 16:01         ` bob zhang
2012-05-31 17:28           ` Gerd Stolpmann
2012-05-31 18:03             ` Wojciech Meyer
2012-05-31 18:32               ` Gerd Stolpmann
2012-05-31 18:32             ` Hongbo Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOg1smBbQe0Y8on=w=t76fTngQU6T6CZAGwpqRGh_peyxaBA-A@mail.gmail.com' \
    --to=wojciech.meyer@googlemail.com \
    --cc=bobzhang1988@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).