Thursday, July 10, 2014

Imperative Spaghetti Programming

I was really bored one day and I decided to post this piece of art on Code Review. It is in the process of being deleted because it's too beautiful for the site.

Tested with Visual Studio 2012.

#include <iostream>
using namespace std ;

const int size = 3 ;
const char * names [] = {"Bob", "Alice", "Eve"} ;
int ages [] = {35, 28, 22} ;

int main (void)
{
    int *i = new int ;
    *i = 0 ;

    bool add_ages_please = true ;

Print:
    if (size <= *i) {
        if (add_ages_please)
            goto AddAges ;
            goto CleanUp ;
    }

    cout << names [*i] << " " << ages [*i] << "\n" ;
    ++(*i) ;
    goto Print ;

AddAges:
    --(*i) ;

    ages [*i] += 1 ;

    if (0 < *i) {
        goto AddAges ;
    }

    add_ages_please = false ;
    goto Print ;

CleanUp:
    delete i ;
    i = nullptr ;

    return 0 ;
}
 
"I use nothing but the very best modern
 programming practices. This is mission-critical production quality 
code. The fact that nobody has been able to suggest any improvements is a
 testament to its quality."

No comments:

Post a Comment