[wg-camlp4] Pending issues

Pierre Chambart pierre.chambart at ocamlpro.com
Wed Feb 13 16:03:54 GMT 2013


Le Wed, 13 Feb 2013 14:12:52 +0100,
Alain Frisch <alain.frisch at lexifi.com> a écrit :

> On 2/12/2013 9:12 PM, Pierre Chambart wrote:
> > I would also prefer to
> > restrict that kind of annotation to a small subset of the expression
> > language avoiding as much as possible duplication.
> 
> Just to be clear, do you propose to restrict attributes in general,
> or only those which will be reflected in runtime types?

Only those available at runtime. Other attributes could of course need
to contain classical OCaml, so there is a need for the full syntax.
And when writting syntax extensions, you will already be exposed to the
full OCaml syntax.

What I was thinking of whas that a ppx rewriter could get whatever
expression as attributes, but what remains after applying all rewriters
must be included in a subset that could map to a type like (maybe a bit
too restricitve)

type expr =
  | List of expr list
  | Sum of string * expr
  | Cst of string

without a rewriter this could be written as

type t =
  { a : int with Min 1, Max 5 }

finishing as List [ Sum ("Min","1"); Sum ("Max","5") ]

If something really generic could be needed a case like this is
possible:

  | Dyn of 'a ty * 'a -> expr

It could be generated by a ppx or taken from a variable like:

let var_name = int_of_string (Sys.argv.(1))
type t =
  { a : int with Default var_name }

generating Sum ("Default", Dyn (Int,var_name))

-- 
Pierre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.ocaml.org/pipermail/wg-camlp4/attachments/20130213/9ecc142a/attachment.sig>


More information about the wg-camlp4 mailing list