go-capnp
go-capnp copied to clipboard
pogs: handle parameterized types
While Go does not have generics, specific applications may want to create pogs-structs that instantiate a generic Cap'n Proto type with specific parameters. For instance, a map struct:
struct Map(Key, Value) {
entries @0 :List(Entry);
struct Entry {
key @0 :Key;
value @1 :Value;
}
}
may want to be mapped to (Text, Data)
:
type TextDataMap struct {
Entries []TextDataEntry
}
type TextDataEntry struct {
Key string
Value []byte
}
This is simpler in the case where the schema itself provides arguments to the type, but this should also consider how the application could pass the parameters. pogs could infer the layout of the (Text, Data)
example just by examining the Go types, but would likely be unable to infer the layout of (Text, Person)
, where Person
is a struct.