Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^8: Can you explain the result?

by Corion (Pope)
on Dec 06, 2011 at 14:48 UTC ( #942043=note: print w/replies, xml ) Need Help??

in reply to Re^7: Can you explain the result?
in thread Can you explain the result?

return affects control flow, which a function in general cannot (leaving Coro aside). Execution after a function returns will always resume right after where the function was called.

The only built-in function that somewhat affects control flow is exit.

Replies are listed 'Best First'.
Re^9: Can you explain the result?
by Lotus1 (Curate) on Dec 06, 2011 at 17:43 UTC

    There are also goto, next, last.

    In the context of the vague assertion I was replying to there is no difference in my opinion. When 'return' is called it does it's job just as when 'open' is called. The difference the OP doesn't seem to grasp is that when return is called, anything after it in that block doesn't execute (how could it?) This is by design and is how other languages work.

      Sure, but all of these four are keywords, and not functions - this is what makes them special.

      But in the context of parsing, they are not really treated that special from (prototyped) functions, so there is no difference in that sense. Well - I'm not sure whether it's possible to pass a label to a function. My naive approach doesn't pass strict:

      use strict; sub bar($) { print shift }; FOO: { bar FOO; };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942043]
[oiskuu]: Discipulus, from the edge or from the top?
[Discipulus]: oiskuu from the top aka 0-0 coords
[LanX]: edge or node?
[oiskuu]: from each height difference, there's a fixed number of "moves right" - "moves left". So it's a number of combinations.
[Discipulus]: I already know how much distinct paths exists but to demonstrate the property i want to have them all
[oiskuu]: ie C(n, k); where n is height difference, k is position in the line
[Discipulus]: infact there are 70 distinct path to reach the tale wich holds 70

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2018-03-19 11:03 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (239 votes). Check out past polls.