caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Peter Zotov <whitequark@whitequark.org>
To: Alain Frisch <alain@frisch.fr>
Cc: caml-list <caml-list@inria.fr>, wg-camlp4@lists.ocaml.org
Subject: Re: [Caml-list] [ANN] ppx_protobuf
Date: Tue, 06 May 2014 08:59:48 +0400	[thread overview]
Message-ID: <5c5c8af234151e7fdc529a63ce305dab@whitequark.org> (raw)
In-Reply-To: <53686514.8070200@frisch.fr>

On 2014-05-06 08:29, Alain Frisch wrote:
> On 5/2/2014 4:29 PM, Peter Zotov wrote:
>> I have just released the first version of ppx_protobuf, a complete
>> Protocol Buffers implementation.
> 
> This is a very cool project, and a good first public use of extension 
> points!

Thanks!

> 
> An aspect of attributes that is not fully settled is how to use
> namespacing in order to ensure that multiple tools interact nicely.
> This topic will hopefully be explored by the community to reach a good
> consensus.
> 
> (a suggestion to recognize both [@x] and [@protobuf.x])

I have designed ppx_protobuf's usage of attributes with exactly this in 
mind;
[@default] especially would be useful for a wide range of type-driven 
code
generators.

I actually intended to release it with the support for namespaced 
attribute
variants ([@protobuf.key]), it has simply been forgotten. I'll include 
it
in the next release.

> 
> Another point: for record fields, you interpret attributes at the
> toplevel of their type. I did not look precisely at the semantics of
> ppx_protobuf, but it seems that it might be more logical to attach
> them to the field directly (do you confirm?):
> 
>   type defaults = {
>      results [@key 1] [@default 10]: int;
>   } [@@protobuf]
> 
> I understand that this form is syntactically "more intrusive" in the
> non-decorated type definition.  Is it the reason to use:
> 
>   type defaults = {
>      results : int [@key 1] [@default 10];
>   } [@@protobuf]
> 
> ?
> 
> I don't see anything wrong with doing so, although it might be worth
> supporting both forms.

The issue here is that I want to support "immediate tuples" (i.e.
"field : int * int", or, more importantly, "A of int * int", which
are semantically equivalent to and represented as a Protobuf message.
As such, I felt it would be only consistent to have the same syntax
for specifying options on an immediate tuple of several elements:

   results : int [@encoding zigzag] * int [@encoding bits32]

and for specifying options on a "tuple of one element":

   results : int [@encoding zigzag]

I'm not entirely happy with this scheme; the way it gives rise to the 
message
structure is at best confusing, as adding or removing a tuple element 
can
add or remove nesting and thus break protocol compatibility. In 
addition,
the [@key] attribute on, for example, a field itself would currently be 
ignored.
While this behavior can be fixed for the most common misplacements, I 
feel like
it's a drawback intrinsic to the extension points mechanism: misplaced 
or misnamed
attributes are going to be silently ignored.

Do you have any ideas for a solution? I have toyed with an idea of
a "verifier extension" which would ascertain the lack of attributes 
after
all the rewriter passes have presumably removed the attributes known
to them, but it wouldn't work  with generic attributes like [@default] 
that
must be shared between extensions.

> 
> 
> -- Alain

-- 
Peter Zotov
sip:whitequark@sipnet.ru


  reply	other threads:[~2014-05-06  4:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02 14:29 Peter Zotov
2014-05-03 16:08 ` Malcolm Matalka
2014-05-03 16:24   ` Peter Zotov
2014-05-03 18:46     ` Malcolm Matalka
2014-05-03 18:52       ` Peter Zotov
2014-05-04  4:49         ` Malcolm Matalka
2014-05-04  8:55           ` Peter Zotov
2014-05-04 15:18             ` Malcolm Matalka
2014-05-04 22:21               ` Peter Zotov
2014-05-04 22:38                 ` Daniel Bünzli
2014-05-04 20:34             ` Gerd Stolpmann
2014-05-06  4:29 ` Alain Frisch
2014-05-06  4:59   ` Peter Zotov [this message]
2014-05-06  7:33     ` Alain Frisch
2014-05-06 10:42   ` Malcolm Matalka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c5c8af234151e7fdc529a63ce305dab@whitequark.org \
    --to=whitequark@whitequark.org \
    --cc=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=wg-camlp4@lists.ocaml.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).