[wg-camlp4] A new branch to experiment with extension points
Yaron Minsky
yminsky at janestreet.com
Fri Mar 1 15:31:54 GMT 2013
On Fri, Mar 1, 2013 at 8:47 AM, Markus Mottl <markus.mottl at gmail.com> wrote:
> It would be great to have one uniform syntax for syntax extensions. I
> don't think we absolutely should keep type_conv like extensions if a
> new approach can replace them. I can understand that industrial users
> that have thousands of legacy annotations will not be happy having to
> change their sources. But I think updating sources could be safely
> automated to a large extent, and any remaining fixes could be applied
> with a little elbow grease.
I do think that "with (:sexp)" is of no real benefit to us. There's
some value in keeping the syntax largely as it was (i.e., "with sexp,
bin_io"), but if we're going to change the syntax at all, I'd prefer a
clean break.
And we can surely apply some elbow grease to get over the hump.
y
> Regards,
> Markus
>
> On Fri, Mar 1, 2013 at 8:40 AM, Gabriel Scherer
> <gabriel.scherer at gmail.com> wrote:
>> I'm not fond of having "with" as a special case. If you don't support
>> the type-conv or deriving syntax as is, could we take this as an
>> opportunity to go back to an uniform syntax? Type declaration could be
>> handled like any structure item.
>>
>> Don't we want to have attributes on signature items as well?
>>
>> Finally, I bet the non-terminal ".." will get little love, but I'm
>> sure you considered other option (for example just ;;(:foo), but that
>> doesn't work in the toplevel and we really want ";;" to help *avoid*
>> precedence issues) and trust that this is one of the less ugly ones.
>>
>> Is that proposal sufficient to do ocamldoc with structured attributes
>> rather than comments? It looks like it is. Can an annotation node, by
>> itself, stand as a structure item (I'm thinking section comments)?
>>
>> On Fri, Mar 1, 2013 at 2:05 PM, Alain Frisch <alain.frisch at lexifi.com> wrote:
>>> On 03/01/2013 09:08 AM, Mark Shinwell wrote:
>>>>
>>>> 1. If possible, I'd rather see one new syntactic form, rather than
>>>> three.
>>>
>>>
>>> I've made the syntax more uniform, dropped prefix attributes, and added
>>> attributes on type declarations.
>>>
>>> The current syntax is:
>>>
>>> Attributes:
>>>
>>> On expressions: expr (:foo expr)
>>> On type expressions: type (:foo expr)
>>> On structure items: str_item ..(:foo expr)
>>> On type declarations: type t = ... with (:foo1 expr1) (:foo2 expr2)
>>>
>>> Extension nodes:
>>>
>>> On expressions: (&foo expr)
>>> On type expressions: (&foo expr)
>>> On structure items: ..(&foo expr)
>>>
>>>
>>> A type-conv like example (attributes on type expressions and type
>>> declarations):
>>>
>>>
>>> =================================================
>>> type t = {
>>> x : int (:default 42);
>>> y : int (:default 3) (:sexp_drop_default);
>>> z : int (:default 3) (:sexp_drop_if z_test);
>>> } with (:sexp)
>>> =================================================
>>>
>>>
>>> A Bisect-like example (attributes on expressions and structure items):
>>>
>>> =================================================
>>> let f x =
>>> match List.map foo [x; a x; b x] with
>>> | [y1; y2; y3] -> tata
>>> | _ -> (assert false) (:bisect visit)
>>>
>>>
>>> let unused = ()
>>> ..(:bisect ignore)
>>> =================================================
>>>
>>>
>>> A Bolt-like example (extension nodes on expressions):
>>>
>>> =================================================
>>> let funct n =
>>> (&log) "funct(%d)" n LEVEL DEBUG;
>>> for i = 1 to n do
>>> print_endline "..."
>>> done
>>> =================================================
>>>
>>> or:
>>>
>>> =================================================
>>> let funct n =
>>> (&log "funct(%d)" n LEVEL DEBUG);
>>> for i = 1 to n do
>>> print_endline "..."
>>> done
>>> =================================================
>>>
>>>
>>> A map/fold generator (extension nodes on structure item):
>>>
>>> =================================================
>>> type variable = string
>>> and term =
>>> | Var of variable
>>> | Lam of variable * term
>>> | App of term * term
>>>
>>>
>>> ..(&generate_map map term)
>>> =================================================
>>>
>>> or, if we also add extension nodes on class expressions:
>>>
>>> =================================================
>>> type variable = string
>>> and term =
>>> | Var of variable
>>> | Lam of variable * term
>>> | App of term * term
>>>
>>>
>>> class map = (&generate_map term)
>>> =================================================
>>>
>>>
>>>
>>> -- Alain
>>>
>>> _______________________________________________
>>> wg-camlp4 mailing list
>>> wg-camlp4 at lists.ocaml.org
>>> http://lists.ocaml.org/listinfo/wg-camlp4
>> _______________________________________________
>> wg-camlp4 mailing list
>> wg-camlp4 at lists.ocaml.org
>> http://lists.ocaml.org/listinfo/wg-camlp4
>
>
>
> --
> Markus Mottl http://www.ocaml.info markus.mottl at gmail.com
> _______________________________________________
> wg-camlp4 mailing list
> wg-camlp4 at lists.ocaml.org
> http://lists.ocaml.org/listinfo/wg-camlp4
More information about the wg-camlp4
mailing list