go-capnp icon indicating copy to clipboard operation
go-capnp copied to clipboard

pogs: handle parameterized types

Open zombiezen opened this issue 7 years ago • 0 comments

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.

zombiezen avatar Aug 26 '17 00:08 zombiezen