Click here to Skip to main content
16,020,080 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
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 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 9:21
trønderen3-Jan-23 9:21 
GeneralRe: Classic FORTRAN Pin
lewist573-Jan-23 9:49
lewist573-Jan-23 9:49 
GeneralRe: Classic FORTRAN Pin
jsc423-Jan-23 10:53
professionaljsc423-Jan-23 10:53 
GeneralRe: Classic FORTRAN Pin
Peter_in_27803-Jan-23 11:07
professionalPeter_in_27803-Jan-23 11:07 
GeneralRe: Classic FORTRAN Pin
jsc423-Jan-23 23:25
professionaljsc423-Jan-23 23:25 
GeneralRe: Classic FORTRAN Pin
trønderen3-Jan-23 16:54
trønderen3-Jan-23 16:54 
GeneralRe: Classic FORTRAN Pin
lewist574-Jan-23 5:27
lewist574-Jan-23 5:27 
GeneralRe: Classic FORTRAN Pin
trønderen4-Jan-23 8:53
trønderen4-Jan-23 8:53 
GeneralRe: Classic FORTRAN Pin
lewist576-Jan-23 16:02
lewist576-Jan-23 16:02 
GeneralLong filename problems in 2022? Pin
honey the codewitch24-Oct-22 14:40
mvahoney the codewitch24-Oct-22 14:40 
GeneralRe: Long filename problems in 2022? Pin
MarkTJohnson25-Oct-22 7:21
professionalMarkTJohnson25-Oct-22 7:21 

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.