in reply to Re^3: Goto-labels for exception handling?
in thread Goto-labels for exception handling?

> The biggest problem with that being the dynamic scope. If the coder forgets this, the coder will discover the code's control flow jumping to unexpected places.

Exactly and thank you for getting to the point.

Contrary to die I can react to the case of a missing "receptor".

But what if this supposedly missing labeled was already used somewhere up the dynamic scope?

I think this could be solved... but I wanted to see if this wheel was already invented before.

Unfortunately does already the mention of "goto" cause a lot of unrelated emotions ... :/

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

  • Comment on Re^4: Goto-labels for exception handling?

Replies are listed 'Best First'.
Re^5: Goto-labels for exception handling?
by RonW (Parson) on May 15, 2018 at 19:26 UTC

    Personally, when it helps readability and maintainability, I have used goto - just very very rarely. Usually, where goto might be used, last can be used, though sometimes requires also using an error variable.

    As for "missing receptors", the only idea I have come up with is to make sure that all "goto" labels are unique. A major problem doing this is finding all the labels. (Maybe Perl::Critic can help with this.) Pre- or post- fixing labels can reduce collisions, but this is very tedious extra work. Maybe defining Pluggable keywords, for example, throw and catch could automate this.