beepbeep-3 icon indicating copy to clipboard operation
beepbeep-3 copied to clipboard

Type checking for generic processors?

Open sylvainhalle opened this issue 7 years ago • 0 comments

Most processors in the tmf package return Variant as their input and output type. Indeed, the event type of a Fork is determined by the output type of the source it is connected to: there can be a fork of integers, or a fork of strings, etc.

However, this means that type checking is disabled for these processors. So, one can connect a queue source of integers to a fork, and one of the outputs of that fork to the Negation processor, and this will not raise an exception, as the fork is "type-agnostic".

One possibility would be to create a Typable interface, which would allow a processor to be told what are its input and output types. The connect() method would check if one of the processors implements Typable, and if so, call its setType() method and give it the other processor's type.

Not sure if the benefit of a more precise runtime type checking is worth all this machinery (and the extra memory involved in each such processor just to remember types).

sylvainhalle avatar Oct 21 '16 15:10 sylvainhalle