caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Bünzli Daniel" <daniel.buenzli@epfl.ch>
To: Eric Breck <ebreck@cs.cornell.edu>
Cc: caml-list@inria.fr
Subject: Re: On language extensions (was Re: [Caml-list] global record)
Date: Thu, 20 Jul 2006 14:42:13 +0200	[thread overview]
Message-ID: <60FD7628-7F4E-4765-88AD-B3AB7DA987D0@epfl.ch> (raw)
In-Reply-To: <51E3580C-02A1-4344-A5AA-862B580015F1@cs.cornell.edu>

Le 20 juil. 06 à 03:12, Eric Breck a écrit :

> Succinctness is not precisely what I was after so much as locality  
> - in this case, having each option declared in a single location -  
> as opposed to the type definition in one place, the default value  
> in another, the Arg.spec in another, code to print the chosen value  
> of each option in another, and, optionally, the de-ref-ication in  
> another.  Such locality is a basic principle of software  
> engineering, and in this case I don't really know how to achieve it  
> with only a library (and not a syntax extension).

The typechecker (indirectly) gives you that locality, it tells you  
exactly where changes are needed and frankly all this is in the same  
module, maybe even on the same page. If I have to maintain your code  
I'll understand quicker hand made code than your syntax extension  
(especially since I already know how the Arg module works).

> I'm not advocating extending the language willy-nilly, but I feel  
> that any new library already requires some amount of learning to  
> use its particular API, and if a small, local extension to the  
> language vastly shrinks (and localizes) code required to interface  
> to the library, it seems reasonable to me (IMHO).

Api is not new syntax. As a said before when you learn an api you  
only need to understand new semantics.

> As far as readability, I tried to choose syntax that would make  
> clear to a casual reader what was going on, but clearly I'm blinded  
> by having stared at this for awhile now.  As Nicolas Pouillard  
> points out, you can always unsugar the code.

For small examples this can be a solution. But I usually prefer not  
to read machine generated code. Most programmer (I hope) reread their  
code and try to make it readable and elegant, a machine won't.

>> You have no guarantee that (1) an extension will not be
>> broken by the next version of the language and (2) that the author
>> will continue to maintain it.
>
> I'm not sure why either 1 or 2 is more true for a syntax extension  
> than for an arbitrary library, assuming the syntax extension  
> doesn't try to make large-scale changes to the grammar.

I agree on this point for 2 but not on 1. Incompatible language  
changes are rare (inexistant ?) with ocaml.

>> P.S. Even for domain specific languages many things can be done in
>> pure ocaml by embedding the dsl in ocaml using meta-programming
>> techniques.
>
> I'm not sure what you mean here.  I understand meta-programming to  
> mean (roughly) generating code programatically.

I was not specifically talking about your problem here, though I  
could maybe be applied. It was more on using caml to write code that  
should be written in another language (e.g. regexps, sql, etc.),  
instead of writing a horrible language extension that will allow you  
to mix both languages or use caml strings, see [1] for more information.

I'm sorry to say that but I regard (maybe out of ignorance) camlp4 as  
very low level and brittle tool (not to say hack). An obvious proof  
of this to me is the composition problem which is according to  
previous messages is not solved by camlp4.

Best,

Daniel

[1]
@article{967844,
  author = {Conal Elliott and Sigbj\&\#248;rn Finne and Oege De Moor},
  title = {Compiling embedded languages},
  journal = {J. Funct. Program.},
  volume = {13},
  number = {3},
  year = {2003},
  issn = {0956-7968},
  pages = {455--481},
  doi = {http://dx.doi.org/10.1017/S0956796802004574},
  publisher = {Cambridge University Press},
  address = {New York, NY, USA},
  }

  parent reply	other threads:[~2006-07-20 12:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-20  1:12 Eric Breck
2006-07-20  5:16 ` skaller
2006-07-20  6:29   ` Stefano Zacchiroli
2006-07-20  8:57     ` Jean-Marie Gaillourdet
2006-07-20 12:42 ` Bünzli Daniel [this message]
2006-07-20 12:40   ` Camlp4 mysteries (was Re: On language extensions (was Re: [Caml-list] global record)) Martin Jambon
2006-07-20 23:38     ` Alain Frisch
2006-07-21  0:11       ` Martin Jambon
2006-07-21  0:29       ` skaller
2006-07-21  0:31       ` Martin Jambon
  -- strict thread matches above, loose matches on Subject: below --
2006-07-19 17:14 [Caml-list] global record Eric Breck
2006-07-19 19:41 ` On language extensions (was Re: [Caml-list] global record) Daniel Bünzli
2006-07-19 19:57   ` Richard Jones
2006-07-19 20:22     ` Stefano Zacchiroli
2006-07-19 21:33   ` Nicolas Pouillard
2006-07-20  2:57   ` Martin Jambon

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=60FD7628-7F4E-4765-88AD-B3AB7DA987D0@epfl.ch \
    --to=daniel.buenzli@epfl.ch \
    --cc=caml-list@inria.fr \
    --cc=ebreck@cs.cornell.edu \
    /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).