VL typecasting




I am experimenting with VL Interface patch type as I could sometimes use something akin to subtypes in some patches. For instance if I wanted to implement something like the Strategy pattern. Sure there’s also the options of using Delegates but when I want to keep an internal state or have multiple methods, using interfaces should be justifiable.

At first I couldn’t figure out how to force types on generic node inputs/outputs to the Interface class instead of the implementations.

For some it might be obvious but it turns out all you have to do is stick an IO box typed to the Interface to give the compiler a hint. Then you can use the implementing classes as expected.


Wonder if there is a way to cast the object back to one of the implementing classes, but without a fail handling structure it’s just calling for trouble :)


hello, the name “Interface” is a bit confusing because its the same name as the language feature itself. so might be better to name it IMyCommonFeatures or so.

anyways, you are right, you can manage several instances of it in the same spread. to get only the slices with a specific type you can use OfType (Sequence) and connect a ForEach with a node of the specific type to it. this will properly filter all slices with a specific type out of the common spread.