MScript should warn if script name conflicts with existing command
MScript and MFunction should warn if attempting to create a script that conflicts with the name of en existing command.
Perhaps use exist()
I think this is a good idea, but the current implementation is such that MScripts and MFunctions can be defined even without access to MATLAB (only the engine needs to be running). This was done deliberately, so that users who need to checkout MATLAB licenses (which might be limited in number or restricted by IP) can do the preliminary work with MATLink before getting access to it. With this being the case, there is no way to infer if there is an existing function on the path at definition time. Also, it's not uncommon to create a script with the same name as an existing one (in a different location), and rely on path precedence to automatically pick the right one (e.g., MATLAB's startup.m file is a good example of such use).
I could perhaps
- Check if MATLAB is open (and warn if there's a conflict) or else be quiet
- Check when executing the script/function and warn each time, letting the user
Quietthe warning.
I prefer number 2 above, but I think we can wait and see if there's an interest in this.
I'd say I have interest in it, but I can add the functionality later myself.
It happened to me that have defined a script that shadows builtins by accident, without realizing it. When using the MATLAB GUI, this is not a problem: edit scriptname will open the script if it already exists, which serves as a warning.
Anyway, this can wait until after the release.