[wg-camlp4] PG'OCaml and syntax proliferation
Alain Frisch
alain at frisch.fr
Mon Jan 28 15:54:28 GMT 2013
On 01/28/2013 04:10 PM, Dario Teixeira wrote:
> let fetch_users dbh =
> PGSQL(dbh) "select id, name from users"
>
> This is syntactally incorrect, of course.
I've written Caml code for 17 years, and it was not clear to me that
this is syntactically incorrect, I had to try...
As an alternative but close enough syntax, I suggest:
(PGSQL dbh) "select id, name from users"
or:
(PGSQL) dbg "select id, name from users"
Since a constructor never evaluates to a function, it remains clear
enough that these two forms are special.
> I could go on. Anyway, regardless of choice, one issue comes to mind.
> Presently, code using the PG'OCaml syntax extension is conspicuous by its
> syntactic incorrectness. Therefore, someone unfamiliar with
> PG'OCaml who happened to be looking at code using the syntax
> extension would immediately suspect something camlp4ish was going on.
Good point.
What do you think of the proposals above? They are "trivially" wrong
OCaml code, although not on a strictly syntactic criterion (but a simple
local typing criterion is close enough).
> let fetch_users dbh =
> `PGSQL' (dbh, "select id, name from users")
This is also an option. I agree that it's a good idea to reach some
consensus about such guidelines (and I know it will be difficult, as for
any syntactic choice!).
Alain
More information about the wg-camlp4
mailing list