On Tue, Sep 20, 2016 at 9:48 PM, Dan Appel <[email protected]> wrote:

> Does this mean that every field (including lists) is nullable? That's
> quite a shame. Looks like all my generated fields are going to be
> implicitly-unwrapped-optional, then (reminds me of objective-c translated
> into swift).
>
>
All pointer fields can be null. Because all types in Cap'n Proto have a
default value, you don't need to return optionals; you can return the
default value when a `getFoo()` accessor reads a null. You should
additionally provide `hasFoo()` accessors for when the user actually wants
to distinguish the null case.

However, if you were decoding Cap'n Proto messages into stand-alone
Swift-native plain-old-data structs, then yes, you would in general need to
make pointer fields optional, because otherwise values of a recursive type
(e.g. `struct Bar { bar @0 :Bar; }`) would be infinitely large.

- David

-- 
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 [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to