@@ -1136,19 +1136,20 @@ L<C<line>|/type/CallFrame#method_line> methods, respectively.
1136
1136
= head3 Other compile-time variables:
1137
1137
1138
1138
X < |$?PACKAGE > X < |$?MODULE > X < |$?CLASS > X < |$?ROLE >
1139
- X < |$?GRAMMAR > X < |$?TABSTOP > X < |$?NL > X < |$?ENC >
1139
+ X < |$?GRAMMAR > X < |$?TABSTOP > X < |$?NL > X < |$?ENC > X < |$?DISTRIBUTION >
1140
1140
1141
1141
The following compile time variables allow for a deeper introspection:
1142
1142
1143
1143
= for table
1144
- $?PACKAGE Which package am I in?
1145
- $?MODULE Which module am I in?
1146
- $?CLASS Which class am I in? (as variable)
1147
- $?ROLE Which role am I in? (as variable)
1148
- $?GRAMMAR Which grammar am I in?
1149
- $?TABSTOP How many spaces is a tab in a heredoc or virtual margin?
1150
- $?NL What a vertical newline "\n" means: LF, CR or CRLF
1151
- $?ENC Default encoding of various IO methods, e.g., Str.encode, Buf.decode
1144
+ $?PACKAGE Which package am I in?
1145
+ $?MODULE Which module am I in?
1146
+ $?CLASS Which class am I in? (as variable)
1147
+ $?ROLE Which role am I in? (as variable)
1148
+ $?GRAMMAR Which grammar am I in?
1149
+ $?TABSTOP How many spaces is a tab in a heredoc or virtual margin?
1150
+ $?NL What a vertical newline "\n" means: LF, CR or CRLF
1151
+ $?ENC Default encoding of various IO methods, e.g., Str.encode, Buf.decode
1152
+ $?DISTRIBUTION The L < Distribution|/type/Distribution > of the current compilation unit.
1152
1153
1153
1154
With particular regard to the C < $?NL > , see the L < newline pragma|/language/pragmas > .
1154
1155
@@ -1189,6 +1190,27 @@ for '.' {
1189
1190
}
1190
1191
= end code
1191
1192
1193
+ = head3 X < $?DISTRIBUTION >
1194
+
1195
+ C < $?DISTRIBUTION > provides access to the L < Distribution|/type/Distribution >
1196
+ of the current compilation unit. This gives module authors a way to reference
1197
+ other files in the distribution by their original relative path names, or to
1198
+ view the meta data, without needing to know the underlying file structure (such as
1199
+ how C < CompUnit::Repository::Installation > changes the file layout on installation).
1200
+
1201
+ = begin code
1202
+ unit module MyFoo;
1203
+
1204
+ sub module-version {
1205
+ say "MyFoo is version:";
1206
+ say $?DISTRIBUTION.meta<ver>;
1207
+ }
1208
+
1209
+ sub module-source {
1210
+ say "MyFoo source code:";
1211
+ say $?DISTRIBUTION.content('lib/MyFoo.pm6');
1212
+ }
1213
+ = end code
1192
1214
1193
1215
= head2 Dynamic variables
1194
1216
0 commit comments