# https://www.reddit.com/r/ProgrammingLanguages/comments/q6nlq4/a_new_kind_of_scope/hgebrip
class step { ... } # Predeclare `step` to allow `trusts step`.
class DB {
method !query(\sql) { sql } # `!` marks method as private, except that...
trusts step; # ...`step` is explicitly trusted by `DB`.
}
package step {
our sub getName(\api) { # `our` allows outside code to call `getName`.
my \sql = 'some sql';
api!DB::query(sql); # `trusts step` in `DB` means code in `step`
# package can call private `Database` methods
# (but they must be fully qualified).
}
}
sub processNewHire {
my \db = DB.new;
# db.query; # Uncommenting would yield a run-time error.
step::getName(db); # (If `getName` was explicitly exported, and
# then explicitly imported, it could be called
# without the `step::` qualifier.)
}
say processNewHire; # some sql