Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changes to sentence case refs #2223 and eliminates non-current comment
  • Loading branch information
JJ committed Jul 29, 2018
1 parent 54200d0 commit 9ca6a17
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions doc/Language/variables.pod6
Expand Up @@ -75,7 +75,7 @@ The container type can be set with C<is> in a declaration.
For information on variables without sigils, see
L<sigilless variables|#Sigilless variables>.
=head2 Item and List Assignment
=head2 Item and list assignment
There are two types of variable assignment, I<item assignment> and I<list
assignment>. Both use the equal sign C<=> as operator. The syntax of the
Expand Down Expand Up @@ -193,7 +193,7 @@ only depends on the C<$>.
=end table
=head2 The C<*> Twigil
=head2 The C<*> twigil
X<|$*>
This twigil is used for dynamic variables which are looked up through the caller's, not through the outer,
Expand Down Expand Up @@ -256,7 +256,7 @@ boolean context before using it for anything else:
Dynamic variables can have lexical scope when declared with C<my> or package scope when declared with C<our>. Dynamic resolution and resolution through symbol tables introduced with C<our> are two orthogonal issues.
=head2 The C<?> Twigil
=head2 The C<?> twigil
X<|$?>
Compile-time variables may be addressed via the C<?> twigil. They are known
Expand All @@ -270,7 +270,7 @@ example for this is:
For a list of these special variables, see
L<compile-time variables|/language/variables#Compile-time_variables>.
=head2 The C<!> Twigil
=head2 The C<!> twigil
X<|$!>
L<Attributes|/language/objects#Attributes> are variables that exist per instance
Expand All @@ -293,7 +293,7 @@ you though. For more details on objects, classes and their attributes see
L<object orientation|/language/objects>.
=head2 The C<.> Twigil
=head2 The C<.> twigil
X<|$.>
The C<.> twigil isn't really for variables at all. In fact, something along
Expand Down Expand Up @@ -326,13 +326,13 @@ is also possible:
For more details on objects, classes and their attributes and methods see
L<object orientation|/language/objects>.
=head2 The C<^> Twigil
=head2 The C<^> twigil
X<|$^>
The C<^> twigil declares a formal positional parameter to blocks or
subroutines. Variables of the form C<$^variable> are a type of placeholder
variable. They may be used in bare blocks to declare formal parameters to
that block. So the block in the code
The C<^> twigil declares a formal positional parameter to blocks or subroutines;
that is, variables of the form C<$^variable> are a type of placeholder variable.
They may be used in bare blocks to declare formal parameters to that block. So
the block in the code
my @powers-of-three = 1,3,9…100;
say reduce { $^b - $^a }, 0, |@powers-of-three;
Expand Down Expand Up @@ -362,7 +362,7 @@ Placeholder variables cannot have type constraints or a variable name with a
single upper-case letter (this is disallowed to enable catching some
Perl5-isms).
=head2 The C<:> Twigil
=head2 The C<:> twigil
X<|$:>
The C<:> twigil declares a formal named parameter to a block or subroutine.
Expand All @@ -376,7 +376,7 @@ therefore not ordered using Unicode order, of course). So this:
See L<^> for more details about placeholder variables.
=head2 The C<=> Twigil
=head2 The C<=> twigil
X<|$=>
The C<=> twigil is used to access Pod variables. Every Pod block in the
Expand All @@ -400,7 +400,7 @@ hierarchical data structure through C<$=pod>.
Note that all those C<$=someBlockName> support the C<Positional> and the
C<Associative> roles.
=head2 The C<~> Twigil
=head2 The C<~> twigil
X<|$~>
The C<~> twigil is for referring to sublanguages (called slangs). The
Expand All @@ -426,7 +426,7 @@ augment slang Regex { # derive from $~Regex and then modify $~Regex
}
=end code
=head1 Variable Declarators and Scope
=head1 Variable declarators and scope
Most of the time it's enough to create a new variable using the C<my>
keyword:
Expand Down Expand Up @@ -457,7 +457,7 @@ predefined variables:
temp Restores a variable's value at the end of scope
let Restores a variable's value at the end of scope if the block exits unsuccessfully
=head2 The C<my> Declarator
=head2 The C<my> declarator
Declaring a variable with C<my> gives it lexical scope. This means it only
exists within the current block. For example:
Expand Down Expand Up @@ -520,7 +520,7 @@ variable using L<the * twigil|#The_*_Twigil>. This twigil makes the compiler loo
C<my> is the default scope for subroutines, so C<my sub x() {}> and
C<sub x() {}> do exactly the same thing.
=head2 The C<our> Declarator
=head2 The C<our> declarator
C<our> variables work just like C<my> variables, except that they also
introduce an alias into the symbol table.
Expand Down Expand Up @@ -573,7 +573,7 @@ To skip elements in the list use the anonymous state variable C<$>.
say [$a, %h].perl;
# OUTPUT: «["b", {:th(1)}]␤»
=head2 The C<has> Declarator
=head2 The C<has> declarator
C<has> scopes attributes to instances of a class or role, and methods to
classes or roles. C<has> is implied for methods, so C<has method x() {}>
Expand All @@ -582,7 +582,7 @@ and C<method x() {}> do the same thing.
See L<object orientation|/language/objects> for more documentation and some
examples.
=head2 The C<anon> Declarator
=head2 The C<anon> declarator
The C<anon> declarator prevents a symbol from getting installed in the lexical
scope, the method table and everywhere else.
Expand All @@ -597,7 +597,7 @@ but still aren't installed in a scope:
say %operations<square>.name; # square
say %operations<square>(8); # 64
=head2 The C<state> Declarator
=head2 The C<state> declarator
C<state> declares lexically scoped variables, just like C<my>. However,
initialization happens exactly once the first time the initialization
Expand Down Expand Up @@ -671,7 +671,7 @@ State variables are shared between all threads. The result can be unexpected.
# many other more or less odd variations can be produced
X<|anon state variables>X<|nameless variables>X<|$ (variable)>
=head3 The C<$> Variable
=head3 The C<$> variable
In addition to explicitly declared named state variables, C<$> can be used
as an anonymous state variable without an explicit C<state> declaration.
Expand Down Expand Up @@ -719,7 +719,7 @@ subset DynInt where $ = ::('Int'); # the initializer will be called for each typ
subset DynInt where state $ = ::('Int'); # the initializer is called once, this is a proper cache
=end code
=head3 The C<@> Variable
=head3 The C<@> variable
Similar to the C<$> variable, there is also a L<Positional>
anonymous state variable C<@>.
Expand Down Expand Up @@ -754,7 +754,7 @@ to do anything useful with it.
As with C<$>, each mention of C<@> in a scope introduces a new anonymous
array.
=head3 The C<%> Variable
=head3 The C<%> variable
In addition, there's an L<Associative> anonymous state variable C<%>.
Expand Down Expand Up @@ -786,7 +786,7 @@ access is also possible (with copying to make it useful).
As with the other anonymous state variables, each mention of C<%> within a
given scope will effectively introduce a separate variable.
=head2 The C<augment> Declarator
=head2 The C<augment> declarator
With C<augment>, you can add attributes and methods to existing classes and
grammars, provided you activated the C<MONKEY-TYPING> pragma first.
Expand All @@ -805,7 +805,7 @@ are better solutions.
(In this case, the better solution would be to use a
L<function|/language/functions>).
=head2 The C<temp> Prefix
=head2 The C<temp> prefix
Like C<my>, C<temp> restores the old value of a variable at the end of its
scope. However, C<temp> does not create a new variable.
Expand Down Expand Up @@ -841,7 +841,7 @@ scope. However, C<temp> does not create a new variable.
# </g>
# </g>␤»
=head2 The C<let> Prefix
=head2 The C<let> prefix
Restores the previous value if the block exits unsuccessfully. A
successful exit means the block returned a defined value or a list.
Expand All @@ -864,9 +864,7 @@ stay as 84 because the block returns a defined value (C<say> returns
true). Otherwise the C<die> statement will cause the block to exit
unsuccessfully, resetting the answer to 42.
=comment this is duplicated in operators.pod
=head1 Type Constraints and Initialization
=head1 Type constraints and initialization
Variables have a type constraint via the L<container|/language/containers> they
are bound to, which goes between the declarator and the variable name. The
Expand Down Expand Up @@ -902,7 +900,7 @@ re-applied by assigning C<Nil> to it:
$product = Nil;
say $product; # OUTPUT: «1␤»
=head2 Default Defined Variables Pragma
=head2 Default defined variables pragma
To force all variables to have a L<definitness|/language/mop#index-entry-syntax_DEFINITE-DEFINITE>
constraint, use the pragma C<use variables :D>. The pragma is lexically scoped and can be
Expand Down Expand Up @@ -931,7 +929,7 @@ As the name suggests, this pragma applies only to variables. To effect
the same behaviour on parameters, use the C<use parameters :D> pragma
(currently NYI in Rakudo).
=head1 Special Variables
=head1 Special variables
Perl 6 attempts to use long, descriptive names for special
variables. There are only three special variables that are extra
Expand All @@ -952,7 +950,7 @@ There are three special variables that are available in every block:
=end table
X<|topic variable>
=head3 The C<$_> Variable
=head3 The C<$_> variable
C<$_> is the topic variable. It's the default parameter for blocks that do
not have an explicit signature, so constructs like C<for @array { ... }> and
Expand Down Expand Up @@ -985,7 +983,7 @@ work on C<$_>:
# ij*␤»
X<|match variable>
=head3 The C<$/> Variable
=head3 The C<$/> variable
C<$/> is the match variable. It stores the result of the last
L<Regex|/language/regexes>
Expand Down Expand Up @@ -1015,7 +1013,7 @@ say $/;
# textnode => 「some text」␤»
=end code
=head4 X«Positional Attributes|variable,$0;variable,$1;variable,@()»
=head4 X«Positional attributes|variable,$0;variable,$1;variable,@()»
C<$/> can have positional attributes if the L<Regex|/language/regexes> had
capture-groups in it, which are just formed with parentheses.
Expand All @@ -1034,7 +1032,7 @@ C<@()> can be used.
say @().join; # OUTPUT: «bbbbbdddddeff␤»
=head4 X«Named Attributes|variable,$<named>;variable,%()»
=head4 X«Named attributes|variable,$<named>;variable,%()»
C<$/> can have named attributes if the L<Regex|/language/regexes> had named
capture-groups in it, or if the Regex called out to another Regex.
Expand All @@ -1054,7 +1052,7 @@ be used.
say %().join; # OUTPUT: «"punctuation ....final-word see?"␤»
X<|error variable>
=head3 The C<$!> Variable
=head3 The C<$!> variable
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,
Expand Down Expand Up @@ -1162,7 +1160,7 @@ C<:bin> will be set on the L<IO::ArgFiles> object.
Arguments from the command line.
X<|$*IN>X<|$*OUT>X<|$*ERR>
=head3 Special Filehandles: STDIN, STDOUT and STDERR
=head3 Special filehandles: C<STDIN>, C<STDOUT> and C<STDERR>
For more information about special filehandles please see also the L<Input and
Output|/language/io> page and the L<IO::Special> class. L<IO::Handle> contains
Expand All @@ -1178,7 +1176,7 @@ Standard output filehandle, AKA I<STDOUT>.
=item C<$*ERR>
Standard error filehandle, AKA I<STDERR>.
=head3 Runtime Environment
=head3 Runtime environment
X<|%*ENV>
=item C<%*ENV>
Environment variables;
Expand Down Expand Up @@ -1323,7 +1321,7 @@ default changed before using them:
This behavior is not tested in the spec tests and is subject to change.
=head1 Naming Conventions
=head1 Naming conventions
It is helpful to know our naming conventions in order to understand what codes
do directly. However, there is not yet a conventions list covering anywhere.
Expand Down

0 comments on commit 9ca6a17

Please sign in to comment.