http://qs1969.pair.com?node_id=384889


in reply to Obfu Coroutines

Sometimes obfu just happens. But unexpected obfuscation is most likely to happen when trying to play interesting games with control of flow.

I still remember with my shock reading an early version of Switch and encountering the line, goto $__;. After discussion with TheDamian I realized that he was right, there was no other way to achieve the promised control of flow. (One of two necessary uses of the traditional goto that I know of in Perl! Bonus points to anyone who can guess the other.)

In fact that line is still there, but thankfully $__ has a better name.

For another view of how one might implement goto in a language which doesn't support it, see Coroutines in C. The technique presented there is actually used in a popular piece of software. (PuTTY. If you're on Windows and need a decent ssh client, get it.) That article is aimed at C, and uses the pre-processor to work its magic.

He also accidentally wound up obfuscating his code. So much so that he felt compelled to write an article explaining why his approach really was natural and obvious, despite the obvious things which people can object to in it.