A custom type is definitely better for two reasons:
The methods you write only encapsulates one concept at a time, and not via 
if end elses the concept of step and impulse in one method body.
Also, it's faster as multiple dispatch allows to call the function 
directly, instead of determining which code to execute via if/else.
By the way, you can also use symbols as type Parameter:
immutable DrivingFunction{Typ} end
const step = DrivingFunction{:step}()

Am Montag, 12. Januar 2015 20:09:54 UTC+1 schrieb James Crist:
>
> I'm currently writing a control theory package for Julia. The MATLAB 
> control theory toolbox has been around forever, and is *the standard* 
> grammar for the field. Almost all control theory packages in other 
> languages just replicate the same set of functions, with the same names. 
> The function names are so hardcoded into me, that I'm reluctant to change 
> them.
>
> That said, several of them conflict with Julia base function names. For 
> example:
>
> `zero(sys::LTISystem)` would compute the zeros of the system in MATLAB, 
> but in Julia this should create the "zero-valued" system
>
> `step(sys::LTISystem)` computes the step-response, but in julia it gives 
> the step for a range
>
> There are others as well. I see two options here:
>
> 1.) I begrudgingly rename them, and attempt to retrain my muscle-memory 
> when writing code :/
> 2.) Some functions don't do what they do in julia base for these types
>
> #1 probably is for the best, but I'm wondering what the community response 
> is to this? I come from a heavy Python background, and without namespaces, 
> I'm not sure how to handle function name-clashing best.
>

Reply via email to