MATLink icon indicating copy to clipboard operation
MATLink copied to clipboard

MScript should warn if script name conflicts with existing command

Open szhorvat opened this issue 12 years ago • 2 comments

MScript and MFunction should warn if attempting to create a script that conflicts with the name of en existing command.

Perhaps use exist()

szhorvat avatar Apr 10 '13 00:04 szhorvat

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

  1. Check if MATLAB is open (and warn if there's a conflict) or else be quiet
  2. Check when executing the script/function and warn each time, letting the user Quiet the warning.

I prefer number 2 above, but I think we can wait and see if there's an interest in this.

rsmenon avatar Apr 11 '13 21:04 rsmenon

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.

szhorvat avatar Apr 11 '13 22:04 szhorvat