Disable subfunction from user who installs package?

Hey guys, so a fairly basic question I assume. I’ve made a package in which there exists two functions:

readVtk
readVtkArray

Where basically readVtkArray is a function which utilizes readVtk. Currently I am only using “export readVtkArray”, so to get to use readVtk, an user has to do; PackageName.readVtk(input) - but is there anyway to make it so that will not even work? So the user can only use the functions I allow?

I know that an user can go and change the source code in the end, and the purpose of doing this is just to avoid the user, using a wrong function.

Kind regards

No, there is not. Julia, in it’s current form, is focused on making difficult problems easier to solve. It’s not a language focused on stopping people from doing things they shouldn’t.

3 Likes

Okay bummer, not a huge problem anyways, but would be a quality of life improvement in my case at least.

Thanks for the fast answer!

Kind regards

In addition to what Robin said, I would like to add that a solution/workaround to such concerns could lie in a good documentation and naming convention. I would say that prefixing/suffixing private names with an underscore (_) is a rather well-established convention these days, so that if you name your function _readVtk, users of your package should at least get a hint that they’re not supposed to use this function directly. This will be made even more explicit if that naming convention is mentioned in your package documentation.

2 Likes

That is actually a great idea. I will utilize this from now on, thanks! This way it will not interfere with the way Julia works as @rdeits described earlier.

Kind regards