I would not be opposed to adding inheritance in IDL.

FWIW, another way to represent sub-types is through a union field in
the "super" record, i.e.:

record Shape {
  int x;
  int y;
  union subFields { CircleFields, SquareFields }
}

record CircleFields {
  int radius;
}

record SquareFields {
  int size;
}

Then you only need to use instanceof and casts for operations that are
specific to sub-types.

Doug

On Thu, Apr 11, 2013 at 2:51 PM, Alexandre Normand
<[email protected]> wrote:
> Hey,
> I'm wondering what you guys think of adding support for inheritance in avro 
> IDL. We're starting to see unions of different types in our code and they 
> mostly have the same fields. We're basically using unions to do inheritance 
> except that the code that uses it remains cumbersome. The client code needs 
> to do instanceof just to cast to the proper type in order to retrieve a value 
> that is actually present in all types of the union.
>
> It seems like this could be hidden from client by just creating a union of 
> all types extending a parent type defined for a field and generating sources 
> with that type.
>
> Any thoughts?
>
> --
> Alex
>

Reply via email to