MATLAB: Misleading wording in the documentation on Matlab package (+) folders.

documentationpackages

In the page Packages Create Namespaces there are two sections on how to reference package members:
  • From inside the package
  • From outside
When considering the 'within' case, there is an explicit statement:
Functions, classes, and other packages contained in a package are scoped to that package
Further considering how namespaces work in other languages I would have thought that within a package, it would not be necessary to use the package prefix to call other members of a package. Unfortunately however, this seems not to be the case.
+mypack\functionOne.m +mypack\functionTwo.m
If I want to call functionOne from functionTwo, I still have to use mypack.functionOne()
Why is this?? Am I missing something because this just seems very unpractical and makes me wonder about the meaning of the statement:
Functions, classes, and other packages contained in a package are scoped to that package

Best Answer

It does say in the documentation that you've linked under Referencing Package Members Within Packages that "All references to packages, functions, and classes in the package must use the package name prefix, unless you import the package".
In my opinion, it's a very stupid decision by Mathworks that completely kills the usefulness of packages. Rename the package and you've got to edit every single file within the package that references other files in the package.
It also stop the user of your code to simply wrap it into a package name of his choice (that he knows is not going to conflict with another package name) since the user is then force to edit your code to add references to the package name. So, this just moved the problem of you having to choose a name for your function that is not going to conflict with somebody's else functions to you having to choose a name for a package that is going to conflict with somebody's else package.