As part of one of my JuliaMatlab packages, MatLang, I want to write wrapper functions that simulate Matlab like APIs.
What are some guidelines for writing efficient wrappers?
Is using chained if-else efficient defining different options/methods for a function? How can I fully benefit from multiple-dispatch and compile-time optimizations?
How can I pass all the input arguments to an inner function? (multiple arguments)
Is there any way to define a new name for a Julia function?
This happens when the same functions exist in Julia and Matlab like zeros. In my package, I use suffix M, so zerosM is the same as zeros, I just want to write zerosM such way that is exactly the same as zeros.
Alternatively, is there any way to display an error to use the native function name without M for the functions that already exist in Julia?
No, an if ... elseif ... else ... end branch inside the function has nothing to do with methods, it is just a branch. May be fine, but can also be less flexible if you need to extend it. Various other design patterns are possible, see Methods · The Julia Language
outer(args...) = inner(args...)
const zerosM = zeros
just throw an error, eg
zerosM(_...) = error("Toto, I have a feeling we're not in Matlab anymore.")
Hope this helps. However, from your questions it looks like you are just learning Julia. Consider just using it as is, instead of tailoring it to resemble Matlab.
I have this “Problem”, with entropy (thermodynamics vs stadistics) but in your case is worse, as the functions do something similar. a suffix is a good solution. i saw capitalization (Transducer.jl) as an alternative, or you can simply use the package leading ( MatLang.zeros)
I think that some library functions having different names is the easiest part of the transition from Matlab (or any other similar language) to Julia, and is someting that should be tackled from the beginning.
Otherwise, it will be more difficult to ask for help, read code written by others, and contribute to packages.