4 ms·
Can you give me an example where generics would be helpful? I'm not doubting you, my brain is just a little slow today and I'm struggling to think of a scenario
by superfrank 8y ago
Can you give me an example where generics would be helpful? I'm not doubting you, my brain is just a little slow today and I'm struggling to think of a scenario where I feel I would NEED them for gRPC.
- wbl 8y agoIf I was to design a type system I would introduce sum and product as type constructors and some basic types and be done. To make this really work takes polymorphism so you can write list.
- deathanatos 8y agoOption<T>. Protobuf "supports" this particular case via other means: messages are always implicitly nullable, and the WKTs cover primitives, which don't count as messages. Map<K, V>: Protobuf has dedicated syntax for this case.
- calebh 8y agoGenerics and user defined types make it easier to represent more complicated data. Now everyone is just going to have to write custom encoders and decoders to get the data to a Protobuf compatible format, which is pretty much what we do right now with JSON. If you haven't used algebraic/sum types before, I highly recommend trying them out. Once you use them you won't want to go back.