Skip to content

Commit

Permalink
Fixed cross references.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Jun 28, 2010
1 parent bd8b9ed commit e92814d
Show file tree
Hide file tree
Showing 26 changed files with 153 additions and 73 deletions.
4 changes: 2 additions & 2 deletions sections/attributes.pod
Expand Up @@ -5,7 +5,7 @@ Z<attributes>
Named entities in Perl--variables and functions--can have additional metadata
attached to them in the form of I<attributes>. Attributes are names (and,
often, values) which allow certain types of metaprogramming
(L<metaprogramming>).
(L<code_generation>).

=begin sidebar

Expand Down Expand Up @@ -51,7 +51,7 @@ arguments to good effect:

The C<Test> attribute identifies methods which include test assertions, and
optionally identifies the number of assertions the method intends to run.
While introspection (L<introspection>) of these classes could discover the
While introspection (L<reflection>) of these classes could discover the
appropriate test methods, given well-designed solid heuristics, the C<:Test>
attribute makes the code and its intent unambiguous.

Expand Down
2 changes: 1 addition & 1 deletion sections/blessed_references.pod
Expand Up @@ -313,7 +313,7 @@ can work around this for you. Moose handles it nicely as well.
=head3 Strategies for Coping with Blessed References

Avoid C<AUTOLOAD> where possible. If you I<must> use it, use forward
declarations of your subs (L<forward_declaration>) to help Perl know which
declarations of your functions (L<functions>) to help Perl know which
C<AUTOLOAD> will provide the method implementation.

Use accessor methods rather than accessing instance data directly through the
Expand Down
40 changes: 40 additions & 0 deletions sections/builtins.pod
@@ -0,0 +1,40 @@
=head1 Builtins

Z<style>

=for author

describe perlfunc, perldoc -f
note important features:
- arguments
- context
- lvalue/rvalue concerns

This could get large. Here are several divisions of useful operators.

(What did I cover elsewhere?)

string funcs
- chomp, index, lc, lcfirst, length, reverse, index, substr, tr///

numeric funcs
- brief mention should suffice

array funcs
- covered in arrays section

list funcs
- grep, join, map, qw(), reverse, sort

hash funcs
- covered in hashes section

IO funcs
- binmode, close, opendir/closedir, print, readdir, say, select
- -X, glob
- system, fork, exec

time/date handling
- time, localtime, gmtime

=end for
2 changes: 2 additions & 0 deletions sections/chapter_06.pod
@@ -1,5 +1,7 @@
=head1 Regular Expressions

Z<regular_expressions>

X<regular expressions>
X<regex>
X<regular expression engine>
Expand Down
2 changes: 1 addition & 1 deletion sections/closures.pod
Expand Up @@ -3,7 +3,7 @@
Z<closures>

You've seen how functions work (L<functions>). You understand how scope works
(L<scoping>). You know that every time control flow enters a function, that
(L<scope>). You know that every time control flow enters a function, that
function gets a new environment representing that invocation's lexical scope.
You can work with subroutine references (L<references>) and anonymous functions
(L<anonymous_functions>).
Expand Down
1 change: 0 additions & 1 deletion sections/code_generation.pod
Expand Up @@ -16,7 +16,6 @@ objects, and--perhaps--higher-order functions and closures.
X<metaprogramming>
X<code generation>


I<Metaprogramming> (or I<code generation>)--writing programs which write
programs--is another abstraction technique. It can be as clear as exploiting
higher-order programming capabilities or it can be a rathole down which you
Expand Down
2 changes: 1 addition & 1 deletion sections/coercion.pod
@@ -1,7 +1,6 @@
=head2 Coercion

Z<coercion>

X<coercion>

Unlike other languages, where a variable can hold only a particular type of
Expand All @@ -17,6 +16,7 @@ mean>), though you must be specific about your intentions.

=head3 Boolean Coercion

Z<boolean_coercion>
X<coercion; boolean>

Boolean coercion occurs when you test the truth of a value, such as in a C<if>
Expand Down
7 changes: 5 additions & 2 deletions sections/context_philosophy.pod
Expand Up @@ -109,9 +109,12 @@ obvious:

=end programlisting

X<operators; scalar>
X<scalar>

The latter example probably will not do what you expect, at least if you expect
it to return a single item. See the C<scalar> operator (L<scalar_operator>)
for the solution.
it to return a single item. Use the C<scalar> operator to enforce scalar
context on the function call.

=head4 Numeric, String, and Boolean Context

Expand Down
24 changes: 15 additions & 9 deletions sections/control_flow.pod
Expand Up @@ -343,13 +343,13 @@ entire expression.
X<context; conditional>

The conditional directives--C<if>, C<unless>, and the ternary conditional
operator--all evaluate an expression in boolean context (L<context>). As
comparison operators such as C<eq>, C<==>, C<ne>, and C<!=> all produce boolean
results when evaluated, Perl coerces the results of other
expressions--including variables and values--into boolean forms. Empty hashes
and arrays evaluate to false. Scalars containing C<undef>, the values 0 and
0.0, and the empty string evaluate to false. Everything else is true, in the
absence of deeper magic.
operator--all evaluate an expression in boolean context
(L<context_philosophy>). As comparison operators such as C<eq>, C<==>, C<ne>,
and C<!=> all produce boolean results when evaluated, Perl coerces the results
of other expressions--including variables and values--into boolean forms.
Empty hashes and arrays evaluate to false. Scalars containing C<undef>, the
values 0 and 0.0, and the empty string evaluate to false. Everything else is
true, in the absence of deeper magic.

=for author

Expand All @@ -360,7 +360,7 @@ Review the rules on truthiness of scalars again.
=begin sidebar

The C<Want> module available from the CPAN allows you to detect boolean context
within your own subroutines. The core C<overload> pragma (L<overload>,
within your own subroutines. The core C<overloading> pragma (L<overloading>,
L<pragmas>) allows you to specify what your own data types produce when
evaluated in a boolean context.

Expand Down Expand Up @@ -1063,7 +1063,13 @@ The C<when> construct is even more powerful; it can match against many other
types of expressions including scalars, aggregates, references, arbitrary
comparison expressions, and even code references. The "Smart matching in
detail" section of the I<perlsyn> perldoc provides a useful table of all
possible match types. See also L<smart match>.
possible match types.

=for author

Link to smart match.

=end for

=head3 Tailcalls

Expand Down
6 changes: 3 additions & 3 deletions sections/distributions.pod
Expand Up @@ -4,7 +4,7 @@ Z<distributions>

X<distribution>

A I<distribution> is a collection of one or more modules (L<module>) which
A I<distribution> is a collection of one or more modules (L<modules>) which
forms a single redistributable, testable, and installable unit. Effectively
it's a collection of module and metadata.

Expand Down Expand Up @@ -89,8 +89,8 @@ intends to replace. It is still in wide use, though it is in maintenance mode
and receives only the most critical bugfixes. It works with the F<Makefile.PL>
file mentioned earlier.

=item * C<Test::More> (L<writing_tests>) is the basic and most widely used
testing module used to write automated tests for Perl software.
=item * C<Test::More> (L<testing>) is the basic and most widely used testing
module used to write automated tests for Perl software.

=item * C<Test::Harness> and C<prove> (L<running_tests>) are the tools used to
run tests and to interpret and report their results.
Expand Down
8 changes: 4 additions & 4 deletions sections/exceptions.pod
Expand Up @@ -208,9 +208,9 @@ may be worth catching; syntax errors rarely are.

=over 4

=item * Using a disallowed key in a restricted hash (L<restricted_hashes>)
=item * Using a disallowed key in a locked hash (L<locked_hashes>)

=item * Blessing a non-reference (L<bless>)
=item * Blessing a non-reference (L<blessed_references>)

=item * Calling a method on an invalid invocant (L<moose>)

Expand All @@ -224,6 +224,6 @@ may be worth catching; syntax errors rarely are.

=back

If you have enabled fatal lexical warnings (L<lexical_warnings>), you can catch
the exceptions they throw. The same goes for exceptions from C<autodie>
If you have enabled fatal lexical warnings (L<registering_warnings>), you can
catch the exceptions they throw. The same goes for exceptions from C<autodie>
(L<autodie>).
24 changes: 19 additions & 5 deletions sections/functions.pod
@@ -1,6 +1,6 @@
Z<functions>
=head2 Functions

=head2 Declaring Functions
Z<functions>

X<subroutines; declaration>
X<functions; declaration>
Expand All @@ -16,6 +16,20 @@ Use the C<sub> keyword to declare a function:
Now C<greet_me()> is available for invocation anywhere else within the program,
provided that the symbol--the function's name--is visible.

X<forward declaration>
X<functions; forward declaration>

You do not have to I<define> a function at the point you declare it. You may
use a I<forward declaration> to tell Perl that you intend for the function to
exist, then delay its definition:

=begin programlisting

sub greet_sun;

=end programlisting


=begin sidebar

You do not have to declare Perl 5 functions before you use them, except in the
Expand Down Expand Up @@ -257,7 +271,7 @@ remove it from the end of C<@_>):

=head3 Slurping

Z<parameter slurping>
Z<parameter_slurping>
X<parameter slurping>

As with any lvalue assignment to an aggregate, assigning to C<%pets> within the
Expand Down Expand Up @@ -337,8 +351,8 @@ to a function is correct by evaluating C<@_> in scalar context:
=end programlisting

Type checking is more difficult, because of Perl's operator-oriented type
conversions (see L<context>). In cases where you need more strictness,
consider the CPAN module C<Params::Validate>.
conversions (see L<context_philosophy>). In cases where you need more
strictness, consider the CPAN module C<Params::Validate>.

=head2 Namespaces

Expand Down
16 changes: 9 additions & 7 deletions sections/hashes.pod
Expand Up @@ -176,10 +176,10 @@ Even Perl 5 keywords get the autoquoting treatment:

=end programlisting

The unary plus (L<unary>; L<numeric_operators>) turns what would be a bareword
(C<shift>) subject to autoquoting rules into an expression. As this implies,
you can use an arbitrary expression--not only a function call--as the key of a
hash:
The unary plus (L<unary_coercions>; L<numeric_operators>) turns what would be a
bareword (C<shift>) subject to autoquoting rules into an expression. As this
implies, you can use an arbitrary expression--not only a function call--as the
key of a hash:

=begin programlisting

Expand Down Expand Up @@ -522,8 +522,8 @@ its boolean truth. The defined-or assignment operator is new in Perl 5.10.
X<hashes; named parameters>

Hashes can also serve many purposes named parameters passed to functions. If
your function takes several arguments, you can use a slurpy hash (L<parameter
slurping>) to gather key/value pairs into a single hash:
your function takes several arguments, you can use a slurpy hash
(L<parameter_slurping>) to gather key/value pairs into a single hash:

=begin programlisting

Expand Down Expand Up @@ -575,9 +575,11 @@ overwrite the previous values.

=head3 Locking Hashes

Z<locked_hashes>
X<locked hashes>

X<hashes; locked>
X<hashes; locking>
X<locked hashes>

One drawback of hashes is that their keys are barewords which offer little typo
protection (especially compared to the function and variable name protection
Expand Down
4 changes: 2 additions & 2 deletions sections/idioms.pod
Expand Up @@ -84,8 +84,8 @@ uses slightly less memory than the other approach.

=end sidebar

This technique works well with C<import()> (L<import>); you can process as many
parameters as you like before slurping the remainder into a hash:
This technique works well with C<import()> (L<importing>); you can process as
many parameters as you like before slurping the remainder into a hash:

=begin programlisting

Expand Down
14 changes: 7 additions & 7 deletions sections/method_sub_equivalence.pod
Expand Up @@ -2,13 +2,13 @@

Z<method_sub_equivalence>

Perl 5's object system is deliberately minimal (L<objects>). Because a class
is a package, Perl itself makes no strong distinction between a function stored
in a package and a method stored in a package. The same keyword, C<sub>,
expresses both. Documentation and the convention of treating the first
parameter as C<$self> can imply intent to readers of the code, but Perl itself
will treat any function of the appropriate name it can find in an appropriate
package as a method if you try to call it as a method.
Perl 5's object system is deliberately minimal (L<blessed_references>).
Because a class is a package, Perl itself makes no strong distinction between a
function stored in a package and a method stored in a package. The same
keyword, C<sub>, expresses both. Documentation and the convention of treating
the first parameter as C<$self> can imply intent to readers of the code, but
Perl itself will treat any function of the appropriate name it can find in an
appropriate package as a method if you try to call it as a method.

Likewise, you can invoke a method as if it were a function--fully-qualified,
exported, or as a reference--if you pass in your own invocant manually.
Expand Down
12 changes: 8 additions & 4 deletions sections/missing_defaults.pod
Expand Up @@ -39,10 +39,10 @@ scope, of course) with C<no strict>. See C<perldoc strict> for more details.

=head3 The C<warnings> Pragma

The C<warnings> pragma (L<warnings>) controls the reporting of various classes
of warnings in Perl 5, such as attempting to stringify the C<undef> value or
using the wrong type of operator on values. It also warns about the use of
deprecated features.
The C<warnings> pragma (L<handling_warnings>) controls the reporting of various
classes of warnings in Perl 5, such as attempting to stringify the C<undef>
value or using the wrong type of operator on values. It also warns about the
use of deprecated features.

The most useful warnings explain that Perl had trouble understanding what you
meant and had to guess at the proper interpretation. Even though Perl often
Expand Down Expand Up @@ -96,6 +96,10 @@ objects as they are--behave as objects should behave.

=head3 The C<autodie> Pragma

Z<autodie>
X<autodie>
X<pragmas; autodie>

Perl 5's default error checking is parsimonious. If you're not careful to
check the return value of every C<open()> call, for example, you could try to
read from a closed filehandle--or worse, lose data as you try to write to one.
Expand Down
1 change: 1 addition & 0 deletions sections/modules.pod
Expand Up @@ -176,6 +176,7 @@ Portable programs are strict about case even if they don't have to be.

=head3 Exporting

Z<exporting>
X<exporting>

A module can make certain global symbols available to other packages through a
Expand Down
4 changes: 2 additions & 2 deletions sections/names.pod
Expand Up @@ -121,8 +121,8 @@ X<rvalue>

In the latter two lines, using a scalar element of an aggregate as an I<lvalue>
(the target of an assignment, on the left side of the C<=> character) imposes
scalar context (L<context>) on the I<rvalue> (the value assigned, on the right
side of the C<=> character).
scalar context (L<context_philosophy>) on the I<rvalue> (the value assigned, on
the right side of the C<=> character).

X<slicing>

Expand Down
7 changes: 4 additions & 3 deletions sections/nested_data_structures.pod
Expand Up @@ -108,11 +108,12 @@ various types of data structures available in Perl with their syntax.

=head3 Autovivification

Z<autovivification>
X<autovivification>

Perl's DWIMminess (L<DWIM>) extends to nested data structures. When you
attempt to write to a component of a nested data structure, Perl will create
the path through the data structure to that piece if it does not exist:
Perl's expressivity extends to nested data structures. When you attempt to
write to a component of a nested data structure, Perl will create the path
through the data structure to that piece if it does not exist:

=begin programlisting

Expand Down

0 comments on commit e92814d

Please sign in to comment.