Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds variable (rakudo-specific). Refs #2547
  • Loading branch information
JJ committed Jan 10, 2019
1 parent 09a0263 commit 6c1ec11
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions doc/Language/variables.pod6
Expand Up @@ -1114,17 +1114,16 @@ C<$!> is the error variable. If a C<try> block or statement prefix catches
an exception, that exception is stored in C<$!>. If no exception was caught,
C<$!> is set to the C<Any> type object.
Note that C<CATCH> blocks I<do not> set C<$!>. Rather they set C<$_> inside
Note that C<CATCH> blocks I<do not> set C<$!>. Rather, they set C<$_> inside
the block to the caught exception.
X<|$?FILE>X<|$?LINE>X<|::?CLASS>X<|&?BLOCK>X<|%?RESOURCES>
=head2 Compile-time variables
All compile time variables have a question mark as part of the twigil.
Being I<compile time> they cannot
be changed at runtime, however they are valuable in order to introspect
the program.
The most common compile time variables are the following:
All compile time variables have a question mark as part of the twigil. Being
I<compile time> they cannot be changed at runtime, however they are valuable in
order to introspect the program. The most common compile time variables are the
following:
=for table
$?FILE Which file am I in?
Expand Down Expand Up @@ -1152,10 +1151,13 @@ The following compile time variables allow for a deeper introspection:
$?TABSTOP How many spaces is a tab in a heredoc or virtual margin?
$?NL What a vertical newline "\n" means: LF, CR or CRLF
$?ENC Default encoding of various IO methods, e.g., Str.encode, Buf.decode
$?DISTRIBUTION The L<Distribution|/type/Distribution> of the current compilation unit.
$?DISTRIBUTION The Distribution of the current compilation unit.
With particular regard to the C<$?NL>, see the L<newline pragma|/language/pragmas>.
These variables are Rakudo specific, with all the corresponding caveats:
=for table
$?BITS Number of bits of the platform the program is being compiled
=head3 X<&?ROUTINE>
Expand All @@ -1168,7 +1170,7 @@ others method related to C<Sub>:
sub awesome-sub { say &?ROUTINE.name }
awesome-sub # OUTPUT: awesome-sub
The special variable C<&?ROUTINE> allows also for recursion:
It also allows also for recursion:
=begin code
my $counter = 10;
Expand Down Expand Up @@ -1198,8 +1200,9 @@ for '.' {
C<$?DISTRIBUTION> provides access to the L<Distribution|/type/Distribution> of
the current compilation unit. This gives module authors a way to reference other
files in the distribution by their original relative path names, or to view the
metadata, without needing to know the underlying file structure (such as how
C<CompUnit::Repository::Installation> changes the file layout on installation).
metadata (via the C<.meta> method), without needing to know the underlying file
structure (such as how C<CompUnit::Repository::Installation> changes the file
layout on installation).
=begin code :solo
unit module MyFoo;
Expand Down

0 comments on commit 6c1ec11

Please sign in to comment.