Hacker News new | ask | show | jobs
by huhtenberg 6346 days ago
That code is really bad. Dunno about you, but to me this handcrafted entanglement looks like the crap that any professional programmer should be ashamed of:

  if ( .. )
  {
     for ( .. )
     {
  label:
        ...
     }
  }
  else
  {
     if ( .. )
     {
       ..
     }
     else
       goto label;
     ..
   }
The actual code is even worse than this as there's a second goto that jumps from the top for into one of else blocks at the bottom from where the control can go back to for via another goto ... I sort of can see how this code came about, but there is absolutely no excuse for checking in something this f*cked up.

If they wanted to show off, they should've just used the coroutines :-)

1 comments

It has been explained that this is just a way of implementing a fast lexical scanner. This is the kind of code that you don't come up with, it is a mechanical implementation of a state machine.
Mechanical or not, this is a very untidy way of implementing a "fast lexical scanner". Even the Duff's device looks cleaner and more elegant in comparison. And it's not like there is a shortage of other implementation options that are as fast.