Skip to content

Commit 3c37050

Browse files
OvidOvid
Ovid
authored andcommitted
Update the PPC to clarify behavior and mention package variables
1 parent aa3c24c commit 3c37050

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

ppcs/ppc0023-lexical-require.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ use feature 'lexical_require`;
2323
use Some::Module;
2424
```
2525
26-
With the above, code outside of the above scope cannot see `Some::Module` unless
27-
it explicitly requires it.
26+
Within a given lexical scope, **ß**, if the 'lexical_require' feature is used,
27+
code outside of scope **ß** cannot call methods against class names that have
28+
not been explicitly required within the current package, and doing so would
29+
throw an exception. Methods would be allowed against any object (blessed
30+
reference), but not against a class.
31+
32+
Note: that doesn't mean the transitive dependencies aren't available. If
33+
scope **ß** uses `lexical_require` and `Hash::Ordered`, but scope **∂** uses
34+
`Hash::Ordered` but _doesn't_ use `lexical_require`, then `Hash::Ordered` is
35+
still available to everyone as a transitive dependency. However, individual module
36+
authors will still have greater safety in knowing that people are not directly
37+
relying on their internals.
2838

2939
## Motivation
3040

@@ -70,6 +80,14 @@ my $object = Some::Class->new; # succeeds if `Some::Class` has a `new` method
7080
my $cache = Hash::Ordered->new; # fails
7181
```
7282

83+
Note that, if possible, this should also apply to package variables. In the
84+
above, `$Hash::Ordered::VERSION` should fail. This is again, to prevent
85+
accidentally relying on code that might not be there. If `Foo` switches from
86+
`Hash::Ordered` to a similar module, all code relying on `Hash::Ordered` as a
87+
transitive dependency would break. As a module author, I don't want to break
88+
someone else's code just because I changed internal details that they should
89+
not know about.
90+
7391
## Backwards Compatibility
7492

7593
This feature should be 100% backwards compatible for new code. If retrofitted

0 commit comments

Comments
 (0)