Skip to content

Commit fa0a8fe

Browse files
committed
Reorganizes dynamic variables closes #2813
Adds `$*DEFAULT-READ-ELEMS` closes #2802 in the new section.
1 parent 64d2f35 commit fa0a8fe

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

doc/Language/variables.pod6

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,27 @@ I<Note:> So far, if you use rakudo perl6, the example below cannot run
221221
correctly in the REPL. Please test it by copy-pasting it into a file, then
222222
run the file.
223223
224-
=begin code
225-
my $lexical = 1;
226-
my $*dynamic1 = 10;
227-
my $*dynamic2 = 100;
224+
=begin code
225+
my $lexical = 1;
226+
my $*dynamic1 = 10;
227+
my $*dynamic2 = 100;
228228
229-
sub say-all() {
230-
say "$lexical, $*dynamic1, $*dynamic2";
231-
}
229+
sub say-all() {
230+
say "$lexical, $*dynamic1, $*dynamic2";
231+
}
232232
233-
say-all(); # OUTPUT: 1, 10, 100
233+
say-all(); # OUTPUT: 1, 10, 100
234234
235-
{
236-
my $lexical = 2;
237-
my $*dynamic1 = 11;
238-
$*dynamic2 = 101;
235+
{
236+
my $lexical = 2;
237+
my $*dynamic1 = 11;
238+
$*dynamic2 = 101;
239239
240-
say-all(); # OUTPUT: 1, 11, 101
241-
}
240+
say-all(); # OUTPUT: 1, 11, 101
241+
}
242242
243-
say-all(); # OUTPUT: 1, 10, 101
244-
=end code
243+
say-all(); # OUTPUT: 1, 10, 101
244+
=end code
245245
246246
The first time C<&say-all> is called, it prints "C<1, 10, 100>" just as one
247247
would expect. The second time though, it prints "C<1, 11, 101>". This is
@@ -259,17 +259,17 @@ runtime L<failure|/type/Failure>, so a dynamic variable can be used
259259
undeclared as long as it's checked for definedness or used in a
260260
boolean context before using it for anything else:
261261
262-
=begin code
263-
sub foo() {
264-
$*FOO // 'foo';
265-
}
262+
=begin code
263+
sub foo() {
264+
$*FOO // 'foo';
265+
}
266266
267-
say foo; # OUTPUT: «foo␤»
267+
say foo; # OUTPUT: «foo␤»
268268
269-
my $*FOO = 'bar';
269+
my $*FOO = 'bar';
270270
271-
say foo; # OUTPUT: «bar␤»
272-
=end code
271+
say foo; # OUTPUT: «bar␤»
272+
=end code
273273
274274
Dynamic variables can have lexical scope when declared with C<my> or package
275275
scope when declared with C<our>. Dynamic resolution and resolution through
@@ -1120,9 +1120,10 @@ This I<magic> behavior of C<@()> has been deprecated as of 6.d
11201120
C<$/> can have named attributes if the L<Regex|/language/regexes> had named
11211121
capture-groups in it, or if the Regex called out to another Regex.
11221122
1123-
'I... see?' ~~ / \w+ $<punctuation>=[ <-[\w\s]>+ ] \s* $<final-word> = [ \w+ . ] /;
1124-
say $/<punctuation>; # OUTPUT: «「....」␤»
1125-
say $/<final-word>; # OUTPUT: «「see?」␤»
1123+
=for code
1124+
'I... see?' ~~ / \w+ $<punctuation>=[ <-[\w\s]>+ ] \s* $<final-word> = [ \w+ . ] /;
1125+
say $/<punctuation>; # OUTPUT: «「....」␤»
1126+
say $/<final-word>; # OUTPUT: «「see?」␤»
11261127
11271128
These can also be accessed by the shortcut C«$<named>».
11281129
@@ -1512,13 +1513,6 @@ X<|$*TMPDIR>
15121513
This is an L<IO::Path> object representing the "system temporary directory" as
15131514
determined by L«C<.tmpdir IO::Spec::* method>|/routine/tmpdir».
15141515
1515-
X<|$*TOLERANCE>
1516-
=head4 C<$*TOLERANCE>
1517-
1518-
Variable used by the L<C<=~=>|/routine/=~=> operator, and any operations that
1519-
depend on it, to decide if two values are approximately equal. Defaults to
1520-
C<1e-15>.
1521-
15221516
X<|$*THREAD>
15231517
=head4 C<$*THREAD>
15241518
@@ -1561,12 +1555,30 @@ sub MAIN($a, :$b, UInt :$ehehe) {
15611555
15621556
It is accessible only inside of MAIN sub.
15631557
1558+
=head3 Runtime variables
1559+
1560+
These variables affect the behavior of certain functions, and in some cases its
1561+
value can be changed during runtime.
1562+
15641563
X<|$*COLLATION>
15651564
=head4 C<$*COLLATION>
15661565
15671566
This is a L<Collation|/type/Collation> object that can be used to
15681567
configure Unicode collation levels.
15691568
1569+
X<|$*TOLERANCE>
1570+
=head4 C<$*TOLERANCE>
1571+
1572+
Variable used by the L<C<=~=>|/routine/=~=> operator, and any operations that
1573+
depend on it, to decide if two values are approximately equal. Defaults to
1574+
C<1e-15>.
1575+
1576+
X<|$*DEFAULT-READ-ELEMS>
1577+
=head4 C<$*DEFAULT-READ-ELEMS>
1578+
1579+
Affects the number of bytes read by default by
1580+
L<C<IO::Handle.read>|/type/IO::Handle#method_read>. Its default value is 65536.
1581+
15701582
=head1 Naming conventions
15711583
15721584
It is helpful to know our naming conventions in order to understand what codes

0 commit comments

Comments
 (0)