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. Other Discussions
  3. The Weird and The Wonderful
  4. Interesting technique used in some Legacy code!

Interesting technique used in some Legacy code!

Scheduled Pinned Locked Moved The Weird and The Wonderful
26 Posts 12 Posters 3 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.
  • OriginalGriffO OriginalGriff

    Well, the good news is it wasn't hidden away in a header file... :omg: If it's any consolation, A FORTRAN compiler I used to work with years, and years ago would accept a constant value as a function parameter, and let you change it at run time. I can't remember FORTRAN syntax any more but it would be similar to:

    void MyMethod (ref int i)
    {
    i = 666;
    }
    ...
    Console.WriteLine(42);
    MyMethod(42);
    Console.WriteLine(42);

    Would happily print: 42 666

    Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

    M Offline
    M Offline
    mikepwilson
    wrote on last edited by
    #21

    Oh that's some exciting crap right there.

    1 Reply Last reply
    0
    • D DeathByChocolate

      This was at the top of the code:

      #define 300 1
      #define 100 0

      I'm amazed that the compiler even accepted it! :rolleyes:

      "State acheived after eating too many chocolate-covered coconut bars - bountiful" Chris C-B

      S Offline
      S Offline
      Super Lloyd
      wrote on last edited by
      #22

      You forgot ;P

      #define true 0
      #define false 1
      #define maybe true

      My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!

      S 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        No, that implies the wrong thing. The compiler stored all it's constant values in memory locations, so it could happily pass a reference (or more accurately in those days a machine code pointer) to a constant value and it would act like a variable. Total PITA to debug when you met it for the first time: and a hanging offence to leave in production code...

        Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

        C Offline
        C Offline
        cpkilekofp
        wrote on last edited by
        #23

        Geez, I have never actually seen an example of this, but our Fortran and Data Structures instructor mentioned it once on a really old version of Fortran IV.

        "Seize the day" - Horace "It's not what he doesn't know that scares me; it's what he knows for sure that just ain't so!" - Will Rogers, said by him about Herbert Hoover

        OriginalGriffO 1 Reply Last reply
        0
        • C cpkilekofp

          Geez, I have never actually seen an example of this, but our Fortran and Data Structures instructor mentioned it once on a really old version of Fortran IV.

          "Seize the day" - Horace "It's not what he doesn't know that scares me; it's what he knows for sure that just ain't so!" - Will Rogers, said by him about Herbert Hoover

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #24

          You're just trying to make me feel old, aren't you? Well it won't work, I tell you! I have a wife who has that job covered... :sigh:

          Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • S Super Lloyd

            You forgot ;P

            #define true 0
            #define false 1
            #define maybe true

            My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!

            S Offline
            S Offline
            Stefan_Lang
            wrote on last edited by
            #25

            Super Lloyd wrote:

            #define true 0
            #define false 1
            #define maybe true || false

            FTFY ;P

            GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

            S 1 Reply Last reply
            0
            • S Stefan_Lang

              Super Lloyd wrote:

              #define true 0
              #define false 1
              #define maybe true || false

              FTFY ;P

              GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

              S Offline
              S Offline
              Super Lloyd
              wrote on last edited by
              #26

              Much better way of defining maybe, love it! :-D

              My programming get away... The Blog... DirectX for WinRT/C# since 2013! Taking over the world since 1371!

              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