Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Context propagation into subs and evals

by repellent (Priest)
on Feb 20, 2012 at 21:28 UTC ( #955155=note: print w/replies, xml ) Need Help??

in reply to Context propagation into subs and evals

In implicit_returns and no_implicit_returns, did you mean to have an explicit return as in return tst_context() when $_[0] is true?

Replies are listed 'Best First'.
Re^2: Context propagation into subs and evals
by LanX (Bishop) on Feb 20, 2012 at 22:10 UTC
    implicit_returns() has two implicit returns, because the calls to tst_context() could be last statement of the sub.

    Since no_implicit_return() has an explicit return at the end which must be passed, disabling the implicit returns.

    look here

    sub tst { 5 } sub tst { return 5 }
    Both functions are equivalent, but in the latter the return is explicit.

    Cheers Rolf

      Right, I forgot about the return; so I've striked off my question about no_implicit_return.

      As for implicit_return, I guess I got confused as to the purpose of the if statement. Both the true and false code paths lead to an implicit return of the call to tst_context. Me thinks why bother having the if at all? :-)
        The if shows that multiple statements can be returned implicitly and it's not necessarily the undermost statement.

        If you know of a better example illustrating this - at the same time non-trivial and not complex - I'm open for suggestions. :)

        There is a whole bunch of "Flow-Control-Statements" which could play a role here.

        Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://955155]
[LanX]: hmm could be a myth since the root of throne is Greek
[LanX]: erix : the one armed who spent his last years in Dorn castle was a prince of Oranie ;)
[erix]: why does that tell against the Kaiser-story?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-12-15 16:28 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (439 votes). Check out past polls.