Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^11: Short-circuiting a map list. (This works! But ...)

by BrowserUk (Pope)
on Oct 10, 2011 at 01:36 UTC ( #930515=note: print w/ replies, xml ) Need Help??


in reply to Re^10: Short-circuiting a map list. (This works! But ...)
in thread Short-circuiting a map list.

Geez! How many hints do you need?

The "If the last statement is a loop control structure..." restriction comes from here:

  • Like many languages, Perl provides for user-defined subroutines.
  • These may be located anywhere in the main program.
  • Loaded in from other files via the do, require, or use keywords.
  • Any arguments passed in show up in the array @_.
  • A return statement may be used to exit a subroutine.
  • If no return is found and if the last statement is an expression, its value is returned.
  • If the last statement is a loop control structure like a foreach or a while , the returned value is unspecified.
  • Subroutines can return Scalar, Array or Hash.

It is only applied to the "last statement of a subroutine". Not to the last statement of a do block?

For counterpoint, not a millions lines away from where that quote comes from, there is another, rather more applicable quote:

The return value of any block, including those used in subroutines, is taken as the value of the last evaluated expression.

And I'm pretty damn confident that I could find numerous examples of you using, and recommending the use, of the return value from a block.

Does this look familiar:

eval { ...; 1; } or ...;

But suddenly, you read a bit of the documentation, apply it to the wrong circumstance, assume that your misinterpretation is the only interpretation.

I seem to recall that someone fairly authoritative suggested that when the documentation is inadequate or in conflict -- as with those two quotes -- the reference specification is the implementation.

So, jump up and down all you like, you're still drawing the wrong conclusion, and I'm bored with watching you do so. So just stop.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^11: Short-circuiting a map list. (This works! But ...)
Download Code
Re^12: Short-circuiting a map list. (This works! But ...)
by ikegami (Pope) on Oct 10, 2011 at 01:43 UTC

    It is only applied to the "last statement of a subroutine". Not to the last statement of a do block?

    The line you read may only have been talking about the last statement of a subroutine, but it applies for the last statement do blocks and everywhere else a return value is needed from a loop. You've even demonstrated this yourself.

    But suddenly, you read a bit of the documentation, apply it to the wrong circumstance, assume that your misinterpretation is the only interpretation.

    Actually, you're the one who is being a slave to the documentation, not listening to anything else.

    And I'm pretty damn confident that I could find numerous examples of you using, and recommending the use, of the return value from a block.

    Straw man. It's the return value of loops that's not defined, not blocks. eval and do aren't loops.

      I recently suggested conversation with you was like that with a goldfish, but that doesn't do it justice.

      You use a quote from the documentation in support of your misinterpretation.

      I counter, by putting that quote in its rightful context, and highlight your misinterpretation. I then quote another passage from the document you quoted that contradicts your quote (and also happens to support my argument), and then suggest that the implementation is the final arbiter.

      And your response is to ignore all that, and suggest that I am a slave to the documentation.

      Q: How many surrealists does it take to screw in a lightbulb?

      A: Fish.

      Bored now. Just stop.

        You presumed too much if that's what you think.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930515]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2014-10-26 00:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls