Pod nit ([perl #32800])
[p5sagit/p5-mst-13.2.git] / pod / perlsub.pod
index e830130..0839f1b 100644 (file)
@@ -67,7 +67,8 @@ Assigning to the whole array C<@_> removes that aliasing, and does
 not update any arguments.
 
 The return value of a subroutine is the value of the last expression
-evaluated.  More explicitly, a C<return> statement may be used to exit the
+evaluated by that sub, or the empty list in the case of an empty sub.
+More explicitly, a C<return> statement may be used to exit the
 subroutine, optionally specifying the returned value, which will be
 evaluated in the appropriate context (list, scalar, or void) depending
 on the context of the subroutine call.  If you specify no return value,
@@ -211,7 +212,7 @@ C<DESTROY> plus all functions mentioned in L<perltie> and L<PerlIO::via>.
 
 The C<BEGIN>, C<CHECK>, C<INIT> and C<END> subroutines are not so much
 subroutines as named special code blocks, of which you can have more
-than one in a package, and which you can B<not> call explicitely.  See
+than one in a package, and which you can B<not> call explicitly.  See
 L<perlmod/"BEGIN, CHECK, INIT and END">
 
 =head2 Private Variables via my()
@@ -1133,7 +1134,17 @@ The following functions would all be inlined:
     sub FLAG_MASK ()   { FLAG_FOO | FLAG_BAR }
 
     sub OPT_BAZ ()     { not (0x1B58 & FLAG_MASK) }
-    sub BAZ_VAL () {
+
+    sub N () { int(OPT_BAZ) / 3 }
+
+    sub FOO_SET () { 1 if FLAG_MASK & FLAG_FOO }
+
+Be aware that these will not be inlined; as they contain inner scopes,
+the constant folding doesn't reduce them to a single constant:
+
+    sub foo_set () { if (FLAG_MASK & FLAG_FOO) { 1 } }
+
+    sub baz_val () {
        if (OPT_BAZ) {
            return 23;
        }
@@ -1142,13 +1153,6 @@ The following functions would all be inlined:
        }
     }
 
-    sub N () { int(BAZ_VAL) / 3 }
-    BEGIN {
-       my $prod = 1;
-       for (1..N) { $prod *= $_ }
-       sub N_FACTORIAL () { $prod }
-    }
-
 If you redefine a subroutine that was eligible for inlining, you'll get
 a mandatory warning.  (You can use this warning to tell whether or not a
 particular subroutine is considered constant.)  The warning is