2017-06-12 149 views
7

看着source for Int,我看到所有的類都聲明爲my,我認爲這會使它們變爲私有的,並且在該文件之外不可用。但是,他們顯然是。爲什麼他們需要這樣宣佈?爲什麼Rakudo的src/core/Int.pm中的所有類都用my?

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 

我覺得BOOTSTRAP評論與它有關。在Perl6/Metamodel/BOOTSTRAP.nqp有喜歡的臺詞:

my stub Int metaclass Perl6::Metamodel::ClassHOW { ... }; 

回答

7

在Rakudo的src/core/目錄中的文件不會被編譯成自己的私人文件級範圍內獨立的模塊,但串連成構建proceess在一個單一的文件,如gen/moar/CORE.setting。這個'設置'(在其他語言中稱爲'前奏')形成一個隱含地圍繞着你的程序的外部詞法範圍。

該設計在S02: Pseudo-packages中描述,其中的部分內容已進入official documentation

+0

那麼,這些設計可能會在這些文檔中描述,但我不會認爲它與Int.pm中發生的事情有關。謝謝, –

相關問題