Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. The most original code I've ever seen

The most original code I've ever seen

Scheduled Pinned Locked Moved The Lounge
c++delphi
23 Posts 16 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Gabriel 2

    After years programming in C and C++, I thought I've seen it all. But I've found a code so original and complicated as I've never seen before, that I think it worth a look, even if noone would use something like this. Please, don't do things like this. This is a function which can execute in parts. This is, you can return from the function, and when you call it again, it starts processing from where it returned. (This does NOT work in Visual C, I think Borland was used). Anyway, here's the code:

    ORIGINAL CODE |MACRO EXPANSION, FOR CLARITY
    ----------------------------+------------------------------------------------
    #define xxStart \ |
    static int iLine = 0; \ |
    switch (iLine){case 0: |
    |
    #define xxEnd } |
    |
    #define xxReturn(x) \ |
    { iLine=__LINE__; \ |
    return 1; \ |
    case __LINE__:}; |
    |
    int f (void) |int f (void)
    { |{
    xxStart | static int iLine = 0; switch (iLine){case 0:
    |
    ...Processing... | ...Processing...
    |
    if (condition) | if (condition)
    xxReturn(1); | {iLine=__LINE__; return 1; case __LINE__:};
    |
    ...Processing... | ...Processing...
    |
    // More data required | // More data required
    xxReturn(3); | { iLine=__LINE__; return 3; case __LINE__:};
    |
    ...Processing... | ...Processing...
    |
    xxEnd | }
    |
    return 0; | return 0;
    } |}

    G Offline
    G Offline
    Gary R Wheeler
    wrote on last edited by
    #21

    Omigawd, that's wretched :omg:. I've seen that kind of crap before. When I started my current job, I took over a project from a guy who did stuff like the following:

    #define void int

    and

    #define CASEND4 case 5: \
    DoSomething(); \
    break; \
    default: \
    DoSomethingElse(); \
    break;\
    }

    My first official act, after looking this sh*t crap over, was to carefully archive it and then lose the backup.


    Software Zen: delete this;

    T 1 Reply Last reply
    0
    • G Gary R Wheeler

      Omigawd, that's wretched :omg:. I've seen that kind of crap before. When I started my current job, I took over a project from a guy who did stuff like the following:

      #define void int

      and

      #define CASEND4 case 5: \
      DoSomething(); \
      break; \
      default: \
      DoSomethingElse(); \
      break;\
      }

      My first official act, after looking this sh*t crap over, was to carefully archive it and then lose the backup.


      Software Zen: delete this;

      T Offline
      T Offline
      Taka Muraoka
      wrote on last edited by
      #22

      I used to work, doing C, at a place where they had a few Pascal programmers. They had the following defined: #define begin { #define end } I kid you not, we were expected to use them! :omg:


      he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) NEW: Awasu 1.0[^]: A free RSS reader with support for Code Project.

      G 1 Reply Last reply
      0
      • T Taka Muraoka

        I used to work, doing C, at a place where they had a few Pascal programmers. They had the following defined: #define begin { #define end } I kid you not, we were expected to use them! :omg:


        he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed) NEW: Awasu 1.0[^]: A free RSS reader with support for Code Project.

        G Offline
        G Offline
        Gary R Wheeler
        wrote on last edited by
        #23

        Yuck. Unfortunately, in my case, this guy was just plain stupid. He had been a programmer for 25+ years, and nobody ever had the cojones to tell him he wasn't any good at it. Or maybe they did, and he simply didn't get the message. The one good thing was, he was finally laid off, and ended up working for one of our competitors ( :laugh: tee hee :laugh: ).


        Software Zen: delete this;

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups