Language idea: Friend modules #23
Labels
area: language
Issues related to the design of the language.
state: deliberation
Issues that require design work and/or discussion.
Milestone
A module
A
can declare that moduleB
is a friend and so is allowed to access private members ofA
. The keyword is already reserved.Something like this:
a.cel
:b.cel
:For this to work, the semantics of a field expression (
.
operator) would be changed to pass along the accessing module when looking up the member. The runtime would then check if the resolved module declares the accessing module as a friend.This sounds inefficient, but I think object shapes and basic block versioning based on types would allow us to fully specialize most such cases. This feature can only realistically be prototyped and considered once we have a runtime capable of such optimizations.
This is tentatively approved for 2.0, pending prototyping.
The text was updated successfully, but these errors were encountered: