Add a friend
keyword at the module level
#10383
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
friend
keyword at the module level
#10383
The current state of the rules allow using re-exports to control accessibility and visibility of functions and types between modules. However, this suffers from two downsides; first, as @nikomatsakis said in his last comment in #8215, it is impossible to use re-exports to control accessibility and visibility of members and methods. Second, "barrier modules" doing re-exports requires tedious boilerplate code and reduces "code locality" (it is hard to tell where a function is accessible just by looking at it - one needs to also trace the re-exports, which are in other modules).
Adding a module level
friend
keyword would help solving both problems. The idea is that in addition to the existing rules, if a modulefoo
saysfriend mod bar
then the code in the modulebar
can access any private code of the modulefoo
.This is different from the C++
friend
keyword in that it works at the module level, keeping things simple and in line with the general spirit of the current rules.The text was updated successfully, but these errors were encountered: