I think the idea of an unset sentinel value is a little awkward as it
conflates data validation with field presence which are nice concepts to
keep separate (in part for consistency in how you perform data validation).

As I understand it a union is synonymous to a Protobuf oneof field?

Is the recommendation to use a union with only one member or use wrappers
(like this
https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto)
which don't really fix the problem buy minimise it?

Using unions everywhere would make the definitions of messages hard to
read. It suppose some syntactic sugar around this might be useful :/

Thanks for your prompt replies and help BTW. And sorry for my poor reading
of your docs :)

On Thu, 9 Mar 2017 at 19:15 Ross Light <r...@zombiezen.com> wrote:

> Quite the opposite: it's so that scalar values always have a fixed offset
> from the beginning of the struct's data section.  This may waste space on
> the wire, but makes scalar access consistent and avoids branches in the
> common case (read as fast).
>
> However, it's worth noting that reading a scalar field with a newer
> version of the schema will read the default value, so as the FAQ states,
> you can use this property to have an "unset" sentinel value or you can add
> a named union.
>
> On Thu, Mar 9, 2017 at 10:27 AM Sam Duke <samduke...@gmail.com> wrote:
>
> Really confused why this was removed? Is it for less space on the wire?
> Field presence seems an excellent way to guard against regression as protos
> evolve.
>
> On Thu, 9 Mar 2017, 18:20 Ross Light, <r...@zombiezen.com> wrote:
>
> Correct.  In this respect, Cap'n Proto is very close to proto3 semantics.
>
> On Thu, Mar 9, 2017 at 10:08 AM Sam Duke <samduke...@gmail.com> wrote:
>
> Looks like there's no hasX methods for scalars?
>
> On Thu, 9 Mar 2017, 15:57 Ross Light, <r...@zombiezen.com> wrote:
>
> https://capnproto.org/faq.html#how-do-i-make-a-field-optional
>
> On Thu, Mar 9, 2017, 4:01 AM <samduke...@gmail.com> wrote:
>
> I couldn't find an explicit mention of this on the website, curious if
> CapNProto has also removed field presence detection - it's a really useful
> feature to have!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capnproto+unsubscr...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Cap'n Proto" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to capnproto+unsubscr...@googlegroups.com.
> Visit this group at https://groups.google.com/group/capnproto.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to