Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Double feature: the next statement
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Larry Wall  
View profile  
 More options Jan 16 1992, 8:19 pm
Newsgroups: comp.lang.perl
From: lw...@netlabs.com (Larry Wall)
Date: 17 Jan 92 00:54:05 GMT
Local: Thurs, Jan 16 1992 7:54 pm
Subject: Re: Double feature: the next statement
In article <2...@sicsun.epfl.ch> bross...@sicsun.epfl.ch (Alain Brossard) writes:

:
:     This "double feature" is present in Perl 4.019 on a Sun4 running
: sunos 4.1.1.
:       When doing a next within a subroutine which is
: called within a loop and the next itself is NOT within a loop, the next
: is NOT flagged as an error but gives back the control outside the
: subroutine.  This first feature is NOT documented in the perl book and
: I feel that it is a bug since the fact whether the statement is
: syntacticaly valid depends on the USAGE of the subroutine rather than
: its definition!  Without the outside loop, I get an error message:
: Bad label: <null> at - line 4.
:
:     The double part of this feature is that the subroutine can AFFECT
: where the next statement returns OUTSIDE of it!!  In the example below,
: the PRESENCE of the NEVER executed return statement, affects whether
: the statement "next" will give back control just after the call of
: the subroutine or outside the loop which called the subroutine!

Okay, I'll give you a third feature that goes with the other two.  In a
subroutine containing a return, you can say "redo _SUB_" and it will start
the subroutine over.

Here's a fourth.  You can exit an eval by saying "last _EVAL_".

How 'bout this:

    FOO: {
        eval ' print "Ever\n"; eval "redo FOO"; print "Never\n"; ';
    }

These are all accidents of an implementation using longjmp() and a
dynamic label stack, and the wise programmer will not make use of
them.  If you want me to be totally strict about such things, then
don't complain if Perl becomes twice as big, twice as slow, and has to
be rewritten in C++.  I'm sure the Book could have been made twice
as big too.

If I don't document something, it's usually either for a good reason,
or a bad reason.  In this case it's a good reason.  :-)

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.