[net.misc] Bizarre Code

bart@reed.UUCP (Bart Massey) (08/14/85)

> What is the most bizarre line/piece of code you have seen in a production
> program?
> 
> My favorite (in BASIC) is:
> 
> 		X = N & -1
> 
> which is the equivalent of:
> 
> 		X = INT(N)
> 
> 
> I know there must be some better(?) ones out there. Let's see em'.

So name five lines of BASIC you COULDN'T call bizarre!  I've seen
an official 'ls' source ( I don't remember which version of UN*X )
which says

	int i,j;

	....

	i = j << 0;

or some such.  The '<< 0' motif is was repeated several times throughout
the code...

					Bart Massey
					..tektronix!reed!bart

"I want to speak to Dr... uh..."

myers@uwmacc.UUCP (Latitudinarian Lobster) (08/16/85)

> In article <462@moncol.UUCP> john@moncol.UUCP (John Ruschmeyer) writes:
> >What is the most bizarre line/piece of code you have seen in a production
> >program?
> 

Well, this isn't from a production program, but it is a rather cute 2 line
assembly program for the IBM 1130 (Marietta College had one in 1977 that
had 8K of core memory):

	LD	*
	STO	*

The memory was wrap around, so this program would keep storing the store
instruction in the word next to be executed.  Made the pretty lights
blink for a LONG time.

andrew@grkermi.UUCP (Andrew W. Rogers) (08/16/85)

In article <29712@lanl.ARPA> lhl@a.UUCP (Lewis Lowe) writes:
>
>  The most bizarre code I ever had to program follows (in FORTRAN)
>
>  100 IF (IREQ.EQ.0) GO TO 100
>
>and was the accepted method, on a long-defunct system, of testing
>completion on an asynchronous I/O request.

When writing an overlaid program on HP-2100/RTE, you had to include a statement
like

	IF (2 .EQ. 4) CALL MAIN

because the linker wouldn't load the main unless there was a reference to it -
but if you actually *called* MAIN, your program would restart... therefore the
above.  (Optimization?  Constant folding?  What are those?)

AWR