Skip to content

Commit

Permalink
perlop: remove triple-dot
Browse files Browse the repository at this point in the history
This has been superseded by c2f1e22, which adds it
to perlsyn.
  • Loading branch information
Father Chrysostomos committed Jan 6, 2012
1 parent 480e0d3 commit c710240
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 66 deletions.
11 changes: 11 additions & 0 deletions lib/utf8.t
Expand Up @@ -449,6 +449,17 @@ SKIP: {
'utf8::decode respects readonliness';
}

{
# utf8::decode should stringify refs [perl #91850].

package eieifg { use overload '""' => sub { "\x{c3}\x{b3}" },
fallback => 1 }

my $name = bless[], eieifg::;
utf8::decode($name);
is $name, "\xf3", 'utf8::decode flattens references';
}

{
my $a = "456\xb6";
utf8::upgrade($a);
Expand Down
66 changes: 0 additions & 66 deletions pod/perlop.pod
Expand Up @@ -1125,72 +1125,6 @@ lvalues assigned to, and a list assignment in scalar context returns
the number of elements produced by the expression on the right hand
side of the assignment.

=head2 The Triple-Dot Operator
X<...> X<... operator> X<yada-yada operator> X<whatever operator>
X<triple-dot operator>

The triple-dot operator, C<...>, sometimes called the "whatever operator", the
"yada-yada operator", or the "I<et cetera>" operator, is a placeholder for
code. Perl parses it without error, but when you try to execute a whatever,
it throws an exception with the text C<Unimplemented>:

sub unimplemented { ... }

eval { unimplemented() };
if ($@ eq "Unimplemented" ) {
say "Oh look, an exception--whatever.";
}

You can only use the triple-dot operator to stand in for a complete statement.
These examples of the triple-dot work:

{ ... }

sub foo { ... }

...;

eval { ... };

sub foo {
my ($self) = shift;
...;
}

do {
my $variable;
...;
say "Hurrah!";
} while $cheering;

The yada-yada--or whatever--cannot stand in for an expression that is
part of a larger statement since the C<...> is also the three-dot version
of the binary range operator (see L<Range Operators>). These examples of
the whatever operator are still syntax errors:

print ...;

open(PASSWD, ">", "/dev/passwd") or ...;

if ($condition && ...) { say "Hello" }

There are some cases where Perl can't immediately tell the difference
between an expression and a statement. For instance, the syntax for a
block and an anonymous hash reference constructor look the same unless
there's something in the braces that give Perl a hint. The whatever
is a syntax error if Perl doesn't guess that the C<{ ... }> is a
block. In that case, it doesn't think the C<...> is the whatever
because it's expecting an expression instead of a statement:

my @transformed = map { ... } @input; # syntax error

You can use a C<;> inside your block to denote that the C<{ ... }> is
a block and not a hash reference constructor. Now the whatever works:

my @transformed = map {; ... } @input; # ; disambiguates

my @transformed = map { ...; } @input; # ; disambiguates

=head2 Comma Operator
X<comma> X<operator, comma> X<,>

Expand Down
1 change: 1 addition & 0 deletions universal.c
Expand Up @@ -813,6 +813,7 @@ XS(XS_utf8_decode)
SV * const sv = ST(0);
bool RETVAL;
if (SvREADONLY(sv)) sv_force_normal(sv);
SvPV_force_nolen(sv);
RETVAL = sv_utf8_decode(sv);
ST(0) = boolSV(RETVAL);
}
Expand Down

0 comments on commit c710240

Please sign in to comment.