note
tilly
Sometimes obfu just happens. But unexpected obfuscation is most likely to happen when trying to play interesting games with control of flow.<p>
I still remember with my shock reading an early version of [cpan://Switch] and encountering the line, <code>goto $__;</code>. 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.)<p>
In fact that line is still there, but thankfully $__ has a better name.<p>
For another view of how one might implement [goto] in a language which doesn't support it, see [http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html|Coroutines in C]. The technique presented there is <i>actually used</i> in a popular piece of software. ([http://www.chiark.greenend.org.uk/~sgtatham/putty/|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.<p>
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.
384885
384885