Looking at the source for Int, I see that all of the classes are declared with my
, which I would have thought would make them private and not available outside that file. But, they obviously are. Why do they need to be declared that way?
my class Rat { ... }
my class X::Numeric::DivideByZero { ... }
my class X::NYI::BigInt { ... }
my class Int { ... }
my subset UInt of Int where {not .defined or $_ >= 0};
my class Int does Real { # declared in BOOTSTRAP
I figure that BOOTSTRAP comment has something to do with it. In the Perl6/Metamodel/BOOTSTRAP.nqp there are lines like:
my stub Int metaclass Perl6::Metamodel::ClassHOW { ... };
The files in Rakudo's src/core/
directory are not compiled as separate modules with their own private file-level scope, but concatenated into a single file such as gen/moar/CORE.setting
during the build proceess.
Sematically, this 'setting' (known as 'prelude' in other languges) forms an outer lexical scope implicitly surrounding your program.
The design is described in S02: Pseudo-packages, and parts of that section have made it into the official documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With