Skip to content

Commit

Permalink
Some corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Jun 18, 2018
1 parent 7f82b66 commit bec29a8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions doc/Language/terms.pod6
Expand Up @@ -194,7 +194,7 @@ Variables are discussed in the L<variable language docs |/language/variables>.
X<|constant (Terms)>
=head1 Constants
Constants are similar to L<variables/language/variables> that do not
Constants are similar to L<variables|/language/variables> that do not
have a L<container|/language/containers> and cannot be rebound. However,
their initializers are evaluated B<at compile time>:
Expand All @@ -205,10 +205,11 @@ their initializers are evaluated B<at compile time>:
talk @foo; # OUTPUT: «(1 2 3)␤»
Compile-time evaluation means
L<you should be careful|https://docs.perl6.org/language/traps#Constants_are_Compile_Time>
with using contants inside modules, which get automatically pre-compiled,
and so the value of the constant would not change even between
multiple executions of the program:
L<you should be careful|/language/traps#Constants_are_Compile_Time>
with using contants
inside modules, which get automatically pre-compiled, and so the value
of the constant would not change even between multiple executions of the
program:
=begin code
# Foo.pm6
Expand Down Expand Up @@ -251,21 +252,21 @@ of scope declarator is required:
our Int constant foo = 42;
=end code
Unlike L<variables/language/variables>, you cannot parameterize C<@>-,
Unlike L<variables|/language/variables>, you cannot parameterize C<@>-,
C<%>-, and C<&>-sigilled constants by specifying the parameterization type
in the declarator itself:
=begin code :skip<showcasing deliberate compile-time error>
# !!WRONG!! cannot parametarize @-sigilled constant with Int
# !!WRONG!! cannot parameterize @-sigilled constant with Int
our Int constant @foo = 42;
# OK: parametarized types as values are fine
constant @foo = Array[Int].new: 42;
=end code
The reason for the restriction is that constants with C<@> and C<%> sigils
default to L<List> and L<Map> types, which cannot be parametarized. To keep
things simple and consistent, parametarization was simply disallowed in these
default to L<List> and L<Map> types, which cannot be parameterized. To keep
things simple and consistent, parameterization was simply disallowed in these
constructs.
The C<@>-, C<%>-, and C<&>-sigilled constants specify implied typecheck of
Expand Down Expand Up @@ -302,7 +303,7 @@ use backslash before sigilless name of the constant variable (same as with
L<sigilless variables|/language/variables#Sigilless_variables>), and even
omit the name of the constant entirely to have an anonymous constant. Since
you can't refer to anonymous entities, you may be better off using
a L«C<BEGIN> phaser|/language/phasers although» instead, for clarity.
a L«C<BEGIN> phaser|/language/phasers#BEGIN» instead, for clarity.
constant %foo := :{:42foo};
constant \foo = 42;
Expand Down

0 comments on commit bec29a8

Please sign in to comment.