Hi mjbecze, This is interesting! Is this related to:
https://github.com/WebAssembly/design/issues/1274 ? On Sat, Jun 15, 2019 at 9:08 AM <mjbe...@gmail.com> wrote: > Hello, > I'm currently investigating whether capt'n proto schema would be > appropriate for describing Webassebly interfaces. I'm attempting to > translate this interface > <https://github.com/WebAssembly/WASI/blob/master/docs/WASI-overview.md> > to capn proto schema. I several questions and I'm sure I'll have more as > the work progresses. > > 1. Webassebly will soon have opaque references > <https://github.com/WebAssembly/reference-types>. How would you > represent reference types in capt'n proto? > Cap'n Proto's "Capability" type is exactly what you want here: it represents an external reference to "something". Note that interface types in Cap'n Proto are all subclasses of "Capability" -- i.e. "Capability" is kind of like Java's "Object". But it's totally valid to use just the type "Capability" to represent a handle to some opaque thing that has no particular methods you can call. Also worth noting that in Cap'n Proto's real RPC system, capabilities are referenced through table indices, just like Wasm opaque references apparently will be. Check out: https://github.com/capnproto/capnproto/blob/77f20b4652e51b5a7ebda414e979e059a6c7c27c/c++/src/capnp/rpc.capnp#L116 Also, Cap'n Proto's C++ implementation has the ability to attach file descriptors to capabilities and pass them between processes (via SCM_RIGHTS on unix sockets): https://github.com/capnproto/capnproto/pull/821 So there's lots of precedent here. 2. Is annotation the correct way to represent pointers? for example > Oof, this is pretty awkward, especially in that it presumes the callee has the ability to reach into the caller's address space. Obviously, Cap'n Proto hasn't been designed with that sort of thing in mind. With that said, I like your second solution, transforming return values into things that are stored to the pointer. This allows the schema to express the semantics in a way that makes sense for classic RPC, and then return-by-write-to-pointer becomes part of the "calling convention" that maps Cap'n Proto to Wasm. -Kenton -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/CAJouXQ%3DYWW-L4Rp5JZHD5CGTbhiKypWuoP5HJ10CxKqL8A6Z%3Dg%40mail.gmail.com.