Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: How does 'goto LABEL' search for its label? (call stack)

by moritz (Cardinal)
on Jan 17, 2013 at 17:41 UTC ( #1013834=note: print w/replies, xml ) Need Help??

in reply to Re: How does 'goto LABEL' search for its label? (call stack)
in thread How does 'goto LABEL' search for its label?

Thanks tye, your reply did clear up a few things.

I had two problems with my mental model. I didn't remember that that if (0) { } gets optimized away. I also wrongly assumed that each block produces a stack frame.

As for there being a new warning for "if(1){X:...} goto X:", I lack the details for why this got deprecated.

I didn't find many details either, just that without it, the implementation of lexpads would be much simpler and saner.

Now I must go back and study the crufty error handling code I inherited, and see if it can be rescued (or if I can safely argue that it must be rewritten to use something saner).

Replies are listed 'Best First'.
Re^3: How does 'goto LABEL' search for its label? (work-around)
by tye (Sage) on Jan 17, 2013 at 19:42 UTC
    just that without it, the implementation of lexpads would be much simpler and saner.

    Yeah, that would have been my best guess. I'm curious about how "much" simplification we are talking about. But I'll go digging in the p5p archives for more details if I find the time and motivation. :)

    I wonder if the complications could be avoided by having behavior closer to this pseudo-Perl code:

    if( $fatal ) ERR: { ... }

    So that the destination for "goto ERR;" would be the start of the lexical block instead of the first line in the lexical block.

    It would be nice if a label pointing to the first line of a lexical block could just be moved to point to the start of the lexical block, avoiding the complexity and the need for deprecation. That is:

    if( $fatal ) { OK: ... no need to deprecate this ... } if( $fatal ) { my $foo; BAD: ... "goto BAD" from outside this block deprecated ... }

    But, if one ends up using a Perl that has the deprecation but doesn't implement my idea, then it should often be relatively easy to rewrite the code to be more like:

    ... if( $whatever ) { goto ERR; } ... if( $fatal ) { # Used to be "ERR:" here goto ERR; } return ...; ERR: ... code moved from if( $fatal ) ...

    - tye        

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013834]
[marto]: hmm, there are several universities and colleges handy that I'd have thought would offer such services, given this is out of term time, I've no experience of paying for venues :)
[LanX]: OK ...
[LanX]: I have no idea how Mark scouted, giving that he lives in London ... but I think he mentioned his wife being Scottish
[marto]: ah, so this is payback :P
[LanX]: problem with booking venues is that you only know the number of participants a week in advance. ..
[marto]: I guess most cities have areas similar to this, I tend not to mind personally, but would not go out of my way to head down that way
[marto]: it'll probably be fine.
[marto]: LanX: I appreciate that, it's honestly a difficult thing, a fine balance

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-12-14 15:52 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (396 votes). Check out past polls.