[qitab-devel] Nested extensions in cl-protobufs

Hi! I am starting out with cl-protobufs. I would like to interact with a service that is doing the equivalent of the following line of Python, which allows polymorphic treatement of animals, creating a cat and serializing it for transmission to a recipient expecting an Animal (the base message). animal = Animal() animal.type = Animal.Cat cat = animal.Extensions[Cat.animal] # now work with cat... # now serialize animal ... That example is from the tutorial at http://www.indelible.org/ink/protobuf-polymorphism/ which shows the .proto file containing Animal, Cat and Dog messages. How would this code look in cl-protobufs? I'd be most grateful for any clues. I couldn't see anything like like this in the examples (but I admit I'm totally new to the protobufs concepts, and rusty at Lisp, so might have missed it...). Thanks! Thomas

On 21 September 2013 01:10, Thomas Munro <munro@ip9.org> wrote:
animal = Animal() animal.type = Animal.Cat cat = animal.Extensions[Cat.animal] # now work with cat... # now serialize animal ...
I think I worked out how to do this... something like: (let ((animal (make-instance 'animal :type :cat)) (cat (make-instance 'cat))) (setf (animal animal) cat) ;; now work with cat ;; now serialize animal ) Sorry for the noise. And thanks for making cl-protobufs! Thomas Munro
participants (1)
-
Thomas Munro