No documented evolution for method returns

20 views
Skip to first unread message

dre...@gmail.com

unread,
May 29, 2020, 1:27:13 PM5/29/20
to Cap'n Proto
The Evolution section of the schema does not document any way to evolve a return value of a method. Is it possible to evolve function returns, and if so what are the rules? Especially as it applies to returns without parens (can I evolve func @0 () -> :Data; into say func @0 () -> (data :Data, other :Text);)

Kenton Varda

unread,
May 29, 2020, 1:37:31 PM5/29/20
to dre...@gmail.com, Cap'n Proto
Hi,

Indeed, it looks like I forgot to document evolution of return types.

The parenthesized return list is handled the same as the parameter list. You can add new fields to the end, and you should give them default values. These parenthesized lists are actually converted into struct definitions behind the scenes, with the field numbers corresponding to the position of the parameters in the list.

When the parameters or the return type are *not* a parenthesized list, then they are required to name a struct type. In this case, that struct type is used directly, rather than auto-generating an anonymous struct type from the parenthesized list. So, you can convert a parenthesized list to a raw struct or vice versa by ensuring that the parenthesized list's members match the struct's fields.

You gave this example:

    func @0 () -> :Data;

But this is not valid, because `Data` is not a struct type (also, there is a syntax error: there shouldn't be a colon before the type in this context).

-Kenton

On Fri, May 29, 2020 at 12:27 PM <dre...@gmail.com> wrote:
The Evolution section of the schema does not document any way to evolve a return value of a method. Is it possible to evolve function returns, and if so what are the rules? Especially as it applies to returns without parens (can I evolve func @0 () -> :Data; into say func @0 () -> (data :Data, other :Text);)

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/064e09f3-e8ee-49e3-b0dc-022c0b5e68a3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages