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

[FWP] Re: last() dynamically scoped?



[Thread moved out of p5p]

On Sat, Apr 14, 2001 at 10:18:40AM -0400, Mark Mielke wrote:
> On Thu, Apr 12, 2001 at 05:17:48PM -0400, "Chris Nandor" wrote:
> > At 22:08 +0100 2001.04.12, Graham Barr wrote:
> > >That is because a "bare" block is a loop that is executed once.
> > I really want to quote something from Alice in Wonderland here ...
> > Abigail, thanks for the patch.
> 
> But a bare block is different from a non-bare block.
> 
>     $ perl -we '{ if (1) {last} print "1\n" } print "2\n"'
>     2

This is exactly what Graham means.

And what do you mean, different from a non-bare block?

      $ perl -we 'while (1) { if (1) {last} print "1\n" } print "2\n"'   
      2

> Some people are proud of these perl-isms.
> 
> I am not one of these. Call me a purist. And no, I don't like Python very
> much at all (after having been blindly told to go that route more than once -
> not liking a specific perl-ism or 8 does not make a perl blasphemer of me - it
> makes somebody who is critical, likely with an intention to have things
> improve - I wouldn't *be* here, if I chose to never use perl).
> 
> The dynamic scope checking for last() smells very much like a bug kept
> for compatibility's sake (scanning dynamically at run-time was likely
> easier to code way back when - not much of a conscious decision based
> on a functional requirement), and now kept because it looks cute.

That's just fishing for an argument. Can you back that up with facts?

> Pointing at the documentation as a defense for a (mis-)feature, as in,
> "well it is documented that way" is only barely passable as a compatibility
> argument. The people who would lose by eliminating this "functionality"
> are those that are going out of their way to take advantage of obscure
> perl operator sequences, likely for very wrong reasons. Somebody show a
> real programming example where this functionality would actually be
> desired, and "obscured programming contests" don't count.

And who is going to win? If you don't like it, don't use it.

> I have an inkling that perl6 could achieve a fair amount of efficiency
> just by eliminating relatively useless contexts such as this one. The
> perl C compiler certainly does. Loops tend to be critical, and last()
> being a loop control construct, would also likely tend to be critical.
> 
> If the context were to be plugged into last() at compile time, the benefit
> for a really tight loop could potentially be realized at almost every single
> iteration.


Bullocks. Tight loops that execute last at every iteration aren't tight.
Loop optimizations are important for things done many times. But a loop
is exited only once.



Abigail

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