Skip to content

Commit

Permalink
* S04 - Change this example:
Browse files Browse the repository at this point in the history
    if -e { say "exists" } { extra() }

  to this:

    if rand { say "exists" } { extra() }

  Because bare "-e" may be removed along with all $_-defaulting forms
  (to be replaced by .-e), but bare "rand" defaults to 1, and as such
  should probably be still there.


git-svn-id: file:///data/svn/pugs@23433 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
audreyt committed Jun 3, 2006
1 parent ac121f9 commit f14653f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions doc/trunk/design/syn/S04.pod
Expand Up @@ -12,9 +12,9 @@ Larry Wall <larry@wall.org>

Maintainer: Larry Wall <larry@wall.org>
Date: 19 Aug 2004
Last Modified: 5 May 2006
Last Modified: 3 June 2006
Number: 4
Version: 20
Version: 21

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
Expand Down Expand Up @@ -638,18 +638,18 @@ postcircumfix is fine, though.) Any block with whitespace
in front of it will be taken as terminating the conditional, even if
the conditional expression could take another argument. Therefore

if -e { say "exists" } { extra() }
if -e -> $x { say "exists" } { extra() }
if rand { say "exists" } { extra() }
if rand -> $x { say "exists" } { extra() }

is always parsed as

if (-e) { say "exists" }; { extra() }
if (-e) -> $x { say "exists" }; { extra() }
if (rand) { say "exists" }; { extra() }
if (rand) -> $x { say "exists" }; { extra() }

rather than

if (-e { say "exists" }) { extra() }
if (-e (-> $x { say "exists" })) { extra() }
if (rand { say "exists" }) { extra() }
if (rand (-> $x { say "exists" })) { extra() }

Apart from that, it is illegal to use a bare closure where an
operator is expected. (Remove the whitespace if you wish it to be
Expand Down

0 comments on commit f14653f

Please sign in to comment.