[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: last dynamically scoped()? (was Re: [FWP] awww, no fun :()



> I'm not saying I want to solve the halting problem!  But last's
> behavior makes it grossly unpredictable.  With...
> 
>         while($i) { foo(); }
> 
> I know what the conditional is.  Its $i!  If $i is lexical, then the
> scope of code that can control the loop is limited.  If $i is global
> its a wider problem, but its MY PROBLEM and MY CHOICE (where 'me' is
> the author of the looping code) because *I* chose the loop conditions.
> Not the choice of the subroutine I called.  And its immediately
> obvious from the code what lines of investigation I should persue in
> determining the control flow of the loop.

What about the multitude of the dollar-vars. A module could change some
variable that completely changes the behavior of how I print data,
reference arrays (although the first-num-of-array is now deprecated, I
think). This code could be hidden deep within a module that could
adversely affect your code, without you wanting it to. A nice proper
programmer would not use $/ without localizing it. A nice programmer
wouldn't last; within a loop, unless it was his loop.

We trust our functions we call to not do so much stuff, I can't see why
this is any different from the others.

We trust them not to call a c module and edit our bytecode on the fly. We
trust them not to last out of our loop. We trust them not to edit
dollar-vars. We trust them not to go into an infinite loop and crashing
our program. We trust them not to go around jumpsing in our namespaces
and screwing things up, or setting the 'caller's function-reference
in the package to point elsewhere.

What makes this action at a distance this different from every other
function that potentially shields unfriendly perl code?

While I don't think people should use last, I don't think it should be
forcibly deprecated in Perl 5. I think I've actually written code that
might rely on it, somewhere in some production system I've long since
forgotten about. While it seemed good at the time, I don't remember my
reasons for doing it over the 'proper' method. Very strong deprecation
could cause problems with code that ran before, not running anymore. And I
think there's a greater chance of that happening with remote-flow-control
statements than any other types of bug-fixes that are introduced into perl
and change some obscure features of the language.

And personally, I think it's sorta cool to say that perl is able to do a
next from within a loop. It's another thing you can use for japh's,
amazing your peers, and generally doing things fun, with perl.

Mike Lambert



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe