summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
authorRobin Houston <robin@cpan.org>2005-12-30 13:45:34 +0000
committerSteve Peters <steve@fisharerojo.org>2005-12-30 14:39:49 +0000
commit54a85b95f465893ba23bf8c7ad5b933bde134505 (patch)
treedae890d521384ccf17eae246e7488afa6f2b9572 /pod
parent002b9267a385cf8ff0e7534241cdf3798da8636c (diff)
downloadperl-54a85b95f465893ba23bf8c7ad5b933bde134505.tar.gz
Differences from Perl 6
Message-ID: <20051230134534.GA18675@rpc142.cs.man.ac.uk> p4raw-id: //depot/perl@26537
Diffstat (limited to 'pod')
-rw-r--r--pod/perlsyn.pod35
1 files changed, 35 insertions, 0 deletions
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index 3e78c7bd78..e8ef30f09d 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -711,6 +711,41 @@ You can change the way that an object is matched by overloading
the C<~~> operator. This trumps the usual smart match semantics.
See L<overload>.
+=head3 Differences from Perl 6
+
+The Perl 5 smart match and C<given>/C<when> constructs are not
+absolutely identical to their Perl 6 analogues. The most visible
+difference is that, in Perl 5, parentheses are required around
+the argument to C<given()> and C<when()>. Parentheses in Perl 6
+are always optional in a control construct such as C<if()>,
+C<while()>, or C<when()>; they can't be made optional in Perl
+5 without a great deal of potential confusion, because Perl 5
+would parse the expression
+
+ given $foo {
+ ...
+ }
+
+as though the argument to C<given> were an element of the hash
+C<%foo>, interpreting the braces as hash-element syntax.
+
+The table of smart matches is not identical to that proposed
+by the Perl 6 specification Synopsis 4. Some of the differences
+are simply a consequence of Perl 5's different data model, while
+other changes have been made to address problems with the Perl 6
+proposal. For example, the Perl 6 specification implies that
+C<$string ~~ qr/regex/> would test string equality, rather than
+doing a regular expression match. On the other hand, informal
+examples elsewhere make it clear that a regular expression
+match is the intended behaviour. Thus the Synopsis 4 smart
+match specification cannot yet be regarded as definitive.
+
+In Perl 6, C<when()> will always do an implicit smart match
+with its argument, whilst it is convenient in Perl 5 to
+suppress this implicit smart match in certain situations,
+as documented above. (The difference is largely because Perl 5
+does not, even internally, have a boolean type.)
+
=head2 Goto
X<goto>