Author: larry
Date: Tue Jan 22 16:29:21 2008
New Revision: 14494
Modified:
doc/trunk/design/syn/S03.pod
Log:
More tweaks, typos, clarification that "our" differs from in Perl 5
Modified: doc/trunk/design/syn/S03.pod
==============================================================================
--- doc/trunk/design/syn/S03.pod (original)
+++ doc/trunk/design/syn/S03.pod Tue Jan 22 16:29:21 2008
@@ -23,7 +23,7 @@
=head1 Operator precedence
Not counting terms and terminators, Perl 6 has 23 operator precedence
-levels (same as Perl 5, but differently arranged). Here we list the
+levels (same as Perl 5, but differently arranged). Here we list the
levels from "tightest" to "loosest", along with a few examples of
each level:
@@ -1348,7 +1348,7 @@
=item *
-C<< infix:«p5=>» >>, the Perl 5 fatarrow
+C<< infix:«p5=>» >>, the Perl 5 fatarrow
This operator, which behaves exactly like the Perl 5 fatarrow in being
equivalent to a comma, is purely for easier migration from Perl 5
@@ -3580,14 +3580,15 @@
Variable declarators such as C<my> now take a I<signature> as their
argument. (The syntax of function signatures is described more fully in S06.)
-As in the examples above, the parentheses around the signature may be omitted
for a
+
+The parentheses around the signature may be omitted for a
simple declaration that declares a single variable, along with its
associated type, traits and the initializer:
- constant $foo = 123; # okay: initializes $foo to 123
- constant ($foo = 123); # same thing (with explicit parens)
- constant :($foo = 123); # same thing (full Signature form)
- constant ($foo) = 123; # wrong: constants cannot be assigned to
+ constant Dog $foo is woof = 123; # okay: initializes $foo to 123
+ constant (Dog $foo is woof = 123); # same thing (with explicit parens)
+ constant :(Dog $foo is woof = 123); # same thing (full Signature form)
+ constant (Dog $foo is woof) = 123; # wrong: constants cannot be assigned
to
Each declarator can take an initializer following an equals
sign (which should not be confused with a normal assignment, because
@@ -3600,11 +3601,15 @@
state $foo = 1; # happens at START time
constant $foo = 1; # happens at BEGIN time
+(Note that the semantics of C<our> are different from Perl 5, where the
+initialization happens at the same time as a C<my>. To get the same
+effect in Perl 6 you'd have to say "c<(our $foo) = 1;>" instead.)
+
If you do not initialize a container, it starts out undefined at the
beginning of its natural lifetime. (In other words, you can't use
-the old Perl 5 trick of "C<my $foo if 0>" to get a static variable,
+the old Perl 5 trick of "C<my $foo if 0>" to get a static variable,
because a C<my> variable starts out uninitialized every time through
-in Perl 6 rather than retaining its previous value.) Native integer
+in Perl 6 rather than retaining its previous value.) Native integer
containers that do not support the concept of undefined should be
initialized to 0 instead. (Native floating-point containers are
by default initialized to C<NaN>.) Typed object containers start