List Info

Thread: Re: (Documentation?) Bug with 'last'




Re: (Documentation?) Bug with 'last'
user name
2007-10-20 18:04:16
On 10/21/07, Steven Schubiger <schubigergmail.com> wrote:
> Ron Koerner <perlbug-followupperl.org> wrote:
>
> > Let aside that this may make no sense the 'last'
in s1 breaks immediately
> > out of the main loop, instead just out of s1 or
even the if-block.
> >
> > The warning comes to late (i.e. when the
counter-intuitive behaviour of
> > last already occured).
>
> For the sake of completeness, consider:
>
> $ perl -MO=Deparse -e 's1(); sub s1 { if (1) 
}'
>
> s1();
> sub s1 {
>     do {
>         'break'
>     };
> }
>
> So `perldoc -f last` advice applies:
>
> ``last cannot be used to exit a block which returns a
value such as eval {} ,
> sub {}  or do {} , and should not be used to exit a
grep() or map() operation."
>
> > The documentation suggests that a thing like the
above is not possible or
> > forbidden or breaks out of the if-block, but it
does not give a hint to
> > the current behaviour.
>
> I don't think behaviors which shouldn't be used (and
could be subject to change)
> should be documented at all.
>
> > I don't know if this is a real bug (i.e. last
should do something else)
> > or "just" a documentation bug. If it is
the latter it is not really
> > "dwimmy".
>
> Breaking out of an if compbound block when not nested
within a loop seems
> to me not worthy enough either to be documented.

Did you really mean to say 'break' there? Thats C not Perl.

Cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Re: (Documentation?) Bug with 'last'
user name
2007-10-21 04:05:22
demerphq <demerphqgmail.com> wrote:

> Did you really mean to say 'break' there? Thats C not
Perl.

Uh-oh, I know. I meant last, of course.

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )