Many thanks for helping me! @Daniel_Berge, I want to use multiple dispatch in order to call certain methods based on the argument type. To be more specific, I want to write some generic high level wrappers for lab instruments. For example:
function set_voltage(psu::Agilent, volt = 0)
function set_voltage(psu::Tek, volt = 0)
I know this could be handled easily with if/else, but I want to try a different way.
“psu” can contain fields like:
and the “obj” field can be initialized using https://github.com/BBN-Q/Instruments.jl and the “address” field.
Having multiple types of equipment it becomes cumbersome to hardcode manually all the structs with instruments names, so I wanted a way to auto-generate a struct based on the instrument that I need, in order to specialize a method.
I think code is much more readable like this and anyone can add a new method for a different instrument easily.