English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] Generalized Algebraic Datatypes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-10-31 (15:31)
From: Lukasz Stafiniak <lukstafi@g...>
Subject: Re: [Caml-list] Re: Generalized Algebraic Datatypes
On Sun, Oct 31, 2010 at 4:08 PM, Sylvain Le Gall <sylvain@le-gall.net> wrote:
> Function names and values are "low id" in OCaml (first letter must be
> uncapitalized). If you try to define "let MyConstr = 0" in an OCaml
> toplevel, you will get a syntax error...

In unmodified toplevel, but the whole point is to use camlp4 (or camlp5).

> The code generated by camlp4 must be syntactically correct.

No, camlp4 generates syntax trees (i.e. they don't have syntax other
than abstract syntax). (But if there are any asserts in OCaml source
that an AST element called a lower case identifier is actually lower
case, that could be a problem.)

> But maybe you are talking about a deeper integration?

One possibility would be to translate any "Constr" into a value in
contexts where it cannot be parsed as applied to a value, and as
constructor where it is applied to a value... It wouldn't be directly
partially applicable, but it would serve most purposes since it would
work as a function when passed to higher order functions as fold (and
also could be easily rebound).