[wg-camlp4] PG'OCaml and syntax proliferation

Gerd Stolpmann info at gerd-stolpmann.de
Mon Jan 28 20:21:20 GMT 2013


Am 28.01.2013 16:54:28 schrieb(en) Alain Frisch:
> 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!).

I think there are actually two points:

  - whether we want special extensions to the Parsetree for
    preprocessing
  - whether we want special notations for these extensions
    (good for tools, bad for my mind because OCaml is already
    so overloaded with notations)

The second point is not obligatory if you choose to implement the  
first. For example, an extension could register PGSQL as extension  
token. Extension tokens would be handled as a separate type of token by  
the parser. We would then allow

   <exttoken> <expr>+

in expressions and

   <exttoken> <pattern>+

in patterns. We could also define more grammar extensions on type,  
structure and signature level. This way we could "relax" the OCaml  
grammar a bit, without introducing too much new syntactical ideas.

Gerd


> 
> 
> 
> Alain
> _______________________________________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/listinfo/wg-camlp4
> 


-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd at gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


More information about the wg-camlp4 mailing list