Skip to content

Remove functions that conflict with Matlab built-ins#1

Open
cwnaber wants to merge 1 commit into
shanqing-cai:masterfrom
blab-lab:rm_builtins
Open

Remove functions that conflict with Matlab built-ins#1
cwnaber wants to merge 1 commit into
shanqing-cai:masterfrom
blab-lab:rm_builtins

Conversation

@cwnaber

@cwnaber cwnaber commented Dec 30, 2021

Copy link
Copy Markdown

This PR deletes two functions, isfile.m and strsplit.m. Both of these functions share a name with a MATLAB built-in function.

isfile.m

  • Was added as a Matlab built-in in version 2017b. Matlab documentation here.
  • The commonmcode version of isfile functions the same as the Matlab built-in (it returns a boolean value), except that the Matlab built-in can return a vector of values for a vector of filepaths. The commonmcode version can only accept a single filepath.
  • If the user has the commonmcode version of isfile on their Matlab Path when they launch the program, they are shown the warning "Warning: Function isfile has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict." each time.

strsplit.m

  • Was added as a Matlab builtin in version 2013b. Matlab documentation here.
  • As best I can tell, the two functions perform similarly when using one or two input parameters. Our lab has been using this branch over the last year and using Audapter regularly and encountered no issues related to strsplit, except those listed below.
  • However, while the commonmcode version only supports 1 or 2 input parameters, the Matlab version also supports four input arguments. See documentation hyperlink. Other Matlab builtin functions, such as the common doc, call strsplit with 4 input parameters. This causes an error if the commonmcode version of strsplit is used.

Alternatives to deleting the files

Any function in a folder on the Matlab Path will be chosen over a Matlab builtin function. An alternative solution to deleting these files would be to put them in a separate folder. Users could choose to add or not add this separate folder to their Matlab path, depending on if they were using a version of Matlab older than 2017b.

isfile could be rewritten with a call to the Matlab output = dir(filepath), which has existed since 2006b. output.isdir is a boolean describing whether the filepath is a file or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant