object overloads the stringification or the numification operators, and
if overload fallback is active, it will be used instead, as usual.)
+=head2 Labels can't be keywords
+
+Labels used as targets for the C<goto>, C<last>, C<next> or C<redo>
+statements cannot be keywords anymore. This restriction will prevent
+potential confusion between the C<goto LABEL> and C<goto EXPR> syntaxes:
+for example, a statement like C<goto print> would jump to a label whose
+name would be the return value of print(), (usually 1), instead of a
+label named C<print>. Moreover, the other control flow statements
+would just ignore any keyword passed to them as a label name. Since
+such labels cannot be defined anymore, this kind of error will be
+avoided.
+
=head1 Core Enhancements
=head2 The C<overloading> pragma
These tasks would need C knowledge, and knowledge of how the interpreter works,
or a willingness to learn.
-=head2 forbid labels with keyword names
-
-Currently C<goto keyword> "computes" the label value:
-
- $ perl -e 'goto print'
- Can't find label 1 at -e line 1.
-
-It would be nice to forbid labels with keyword names, to avoid confusion.
-
=head2 truncate() prototype
The prototype of truncate() is currently C<$$>. It should probably
not eval "y:echo: eq y|echo|" and
eval "y:echo:ohce: >= 0");
-ok 23, (eval "AUTOLOAD:1" and
+ok 23, (not eval "AUTOLOAD:1" and
not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
not eval "AUTOLOAD:echo:ohce: >= 0");
-ok 24, (eval "and:1" and
+ok 24, (not eval "and:1" and
not eval "and:echo: eq and|echo|" and
not eval "and:echo:ohce: >= 0");
-ok 25, (eval "alarm:1" and
+ok 25, (not eval "alarm:1" and
not eval "alarm:echo: eq alarm|echo|" and
not eval "alarm:echo:ohce: >= 0");
while (d < PL_bufend && isSPACE(*d))
d++; /* no comments skipped here, or s### is misparsed */
+ /* Check for keywords */
+ tmp = keyword(PL_tokenbuf, len, 0);
+
/* Is this a label? */
if (!tmp && PL_expect == XSTATE
&& d < PL_bufend && *d == ':' && *(d + 1) != ':') {
TOKEN(LABEL);
}
- /* Check for keywords */
- tmp = keyword(PL_tokenbuf, len, 0);
-
/* Is this a word before a => operator? */
if (*d == '=' && d[1] == '>') {
CLINE;