Click here to Skip to main content
15,742,882 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Forbidden File Names? Pin
Eddy Vluggen2-Jan-23 22:59
professionalEddy Vluggen2-Jan-23 22:59 
GeneralRe: Forbidden File Names? Pin
kmoorevs3-Jan-23 4:58
kmoorevs3-Jan-23 4:58 
GeneralRe: Forbidden File Names? Pin
Bruce Patin3-Jan-23 3:33
Bruce Patin3-Jan-23 3:33 
GeneralRe: Forbidden File Names? Pin
agolddog3-Jan-23 3:36
agolddog3-Jan-23 3:36 
GeneralRe: Forbidden File Names? Pin
kmoorevs3-Jan-23 4:59
kmoorevs3-Jan-23 4:59 
GeneralRe: Forbidden File Names? Pin
Paul Sanders (the other one)3-Jan-23 3:44
Paul Sanders (the other one)3-Jan-23 3:44 
GeneralRe: Forbidden File Names? Pin
obermd3-Jan-23 3:56
obermd3-Jan-23 3:56 
GeneralRe: Forbidden File Names? Pin
kmoorevs3-Jan-23 5:03
kmoorevs3-Jan-23 5:03 
GeneralRe: Forbidden File Names? Pin
Dave Kreskowiak3-Jan-23 6:41
mveDave Kreskowiak3-Jan-23 6:41 
GeneralRe: Forbidden File Names? Pin
Gee.3-Jan-23 9:34
Gee.3-Jan-23 9:34 
GeneralRe: Forbidden File Names? Pin
kmoorevs3-Jan-23 9:52
kmoorevs3-Jan-23 9:52 
GeneralRe: Forbidden File Names? Pin
trønderen3-Jan-23 19:35
trønderen3-Jan-23 19:35 
GeneralRe: Forbidden File Names? Pin
kmoorevs3-Jan-23 9:46
kmoorevs3-Jan-23 9:46 
GeneralRe: Forbidden File Names? Pin
trønderen3-Jan-23 19:47
trønderen3-Jan-23 19:47 
GeneralRe: Forbidden File Names? Pin
ormonds4-Jan-23 15:18
ormonds4-Jan-23 15:18 
GeneralRe: Forbidden File Names? Pin
englebart15-Jan-23 10:00
professionalenglebart15-Jan-23 10:00 
GeneralRe: Forbidden File Names? Pin
kmoorevs16-Jan-23 7:24
kmoorevs16-Jan-23 7:24 
GeneralRe: Forbidden File Names? Pin
LM Hess29-Jan-23 7:27
LM Hess29-Jan-23 7:27 
GeneralClassic FORTRAN Pin
trønderen30-Dec-22 5:28
trønderen30-Dec-22 5:28 
In a box in the basement, I came across a short source listing from my student days ...

I was a TA at the time. The 'Programming 101' freshmen had been given a fairly simple programming exercise. We, the TAs, were taking the 'Compiler Technics' course, learning that in FORTRAN, there are no reserved words, only tokens with predefined meaning. The context reveals whether the predefined semantics apply, or if the word is a user defined symbol.

So we made up a self-defined exercize: Solve the 'Programming 101' exercize in FORTRAN, using predefined words only, and no numeric constants. (We found no way to generate character values for the WRITE statements, and had to allow ourselves the use of strings.)

Here is the result. We were using a pre-FORTRAN-77 compiler for the development, getting a nicely formatted output. When the F77 compiler arrived, the output was all left justified, but 'mathematically correct'. We tested it on two different F77 compilers, on two diffent machines, and honestly believe that this code is fully F77 compliant. Unfortunately, I do not currently have access to any F77 compiler, so I cannot verify that (and I really, really hope that it is not Fortran 2018 compliant!)

In FORTRAN, space was insignificant. We had a 'compact' version with all the space removed, which made it rather difficult to follow the program flow. So I give you the readable version. One 🍺 to the first one to tell what the printout from this program will be!
FORTRAN
.
      PROGRAM PROGRAM

      INTEGER IF, INTEGER, GOTO, IMPLICIT
      REAL REAL, DIMENSION, EXTERNAL, FORMAT, END
      INTEGER LOGICAL
      REAL COMPLEX, DATA, CALL, ASSIGN, CHARACTER

      DO FOR IF = INTEGER, INTEGER; END DO
      INTEGER = IF + IF
      GOTO = INTEGER * INTEGER * INTEGER * INTEGER - INTEGER - IF

      CALL FUNCTION(IMPLICIT, REAL, DIMENSION, EXTERNAL, FORMAT, END
     $, LOGICAL, COMPLEX, DATA, CALL, ASSIGN, CHARACTER)

      CALL SUBROUTINE(IMPLICIT, LOGICAL, GOTO, IF, INTEGER)

      END


      SUBROUTINE FUNCTION(IMPLICIT, REAL, DIMENSION, EXTERNAL, FORMAT
     $, END, LOGICAL, COMPLEX, DATA, CALL, ASSIGN, CHARACTER)
      RETURN
      END


      SUBROUTINE SUBROUTINE(IMPLICIT, LOGICAL, GOTO, IF, INTEGER)

      INTEGER GOTO, IMPLICIT(GOTO), LOGICAL(GOTO), IF, INTEGER
     $, EXTERNAL, RETURN

      DO FOR EXTERNAL = IF, GOTO
          DO FOR RETURN = EXTERNAL, EXTERNAL - IF
            IMPLICIT(RETURN) = LOGICAL(RETURN) + LOGICAL(RETURN - IF)
          END DO
          IMPLICIT(IF) = IF
          IMPLICIT(EXTERNAL) = IF
          DO FOR RETURN = IF , GOTO - EXTERNAL
            WRITE(IF, '(''$  '')')
          END DO
          DO FOR RETURN = IF, EXTERNAL
            WRITE(IF, '(''$''I4)') IMPLICIT(RETURN)
          END DO
          WRITE(IF, '( /)')
          DO FOR RETURN = IF, GOTO
            LOGICAL(RETURN) = IMPLICIT(RETURN)
          END DO
      END DO
      END

GeneralRe: Classic FORTRAN Pin
Graeme_Grant30-Dec-22 6:32
mvaGraeme_Grant30-Dec-22 6:32 
GeneralRe: Classic FORTRAN Pin
Craig Robbins30-Dec-22 7:21
Craig Robbins30-Dec-22 7:21 
GeneralRe: Classic FORTRAN Pin
Slacker00730-Dec-22 7:36
professionalSlacker00730-Dec-22 7:36 
GeneralRe: Classic FORTRAN Pin
trønderen30-Dec-22 9:18
trønderen30-Dec-22 9:18 
GeneralRe: Classic FORTRAN Pin
haughtonomous2-Jan-23 21:56
haughtonomous2-Jan-23 21:56 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 8:43
lewist573-Jan-23 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.