Goto considered harmful

Y-Combinator recently had an item about The History, Controversy, and Evolution of the Goto Statement [pdf]. The .pdf considers the "right" way to implement code that computes the average of integers read from the standard input, where the value 99999 is used to denote end-of-input. Code written in C is presented on page 10 and is offered as a good solution. It avoids an explicit goto by using a break statement but, in so doing, misses the forest for the trees. It entangles obtaining data with processing the data and this is almost always a bad idea. But C makes it hard to write better code because C doesn't have built-in support for lists. The following Lisp code separates concerns, promotes code reuse, and the only explicit loop construct is the recursive call by read-input to collect data up to the end-of-data sentinel. C needs constructs like for, break, and continue because it's weak on data structures and memory management. It's also a strongly typed language: variables have types and types have values. In Lisp, however, variables have values and values have types which makes it easier to write generic code.

(defun read-input (&optional (result nil))
(let ((value (read)))
(if (equalp value 99999)
(reverse result)
(read-input (cons value result)))))

(defun average (numbers)
(let ((n (length numbers)))
(if (zerop n)
(/ (reduce #'+ numbers) n))))

(defun main ()
(let ((avg (average (read-input))))
(if avg
(format t "~f~%" (float avg))
(format t "no numbers input. average undefined.~%"))))


Story Title

In Georgia, Even The Dog Sneezes

This idea for a story title came to me this morning after a particular bout by my dog, Titan. Harlan Ellison could have produce an award-winning story
just from this title. Too bad he's no longer with us.


Star Trek Memorabilia

[Warning -- links to large files!]

In late July, or early August, 1967 I received
an envelope in the mail from Bill Theiss. The envelope contained seven black and white pictures. One of the U. S. S. Enterprise, and six personally autographed pictures from the cast of Star Trek: William Shatner, Leonard Nimoy, DeForest Kelley, James Doohan, George Takei, and Nichelle Nichols.

grandmother was a neighbor of (or knew -- I wasn't ever really sure) the mother of Susanne Wasson, who played Lethe in the episode Dagger of the Mind from Season 1, Episode 10.

Plato, Church, and Turing

The lambda calculus is the "platonic form" of a Turing machine

     — wrf3

I wrote this in a comment over at Edward Feser's blog in a comment to
Gödel and the mechanization of thought. Google doesn't find it anywhere in this exact form, but this post appears to express the same idea. The components of this idea can be found elsewhere, but it isn't stated as directly as here.

Ancient Publication

Sometime in 1987, or thereabouts, I was working with various Intel processors. For some reason I needed to know which type of CPU some code was running on, so I wrote a routine that would determine whether the processor was an 8086, 80186, 80286, or 80386 and, if a 286 or 386, whether it was running in real or protected mode. I wrote an article about it which was first printed in PC Tech Journal, November 1987, on page 51. Somewhere I still have a copy of that issue. Somewhere. The article was then anthologized in Dr. Dobb's Toolbook of 80286/80306 programming on pages 75 to 78.

The text of the article and the source code is below the fold. I wish I had my original work to show how it was edited for publication.