Errors Acummulate

by Brian Hayes

Published 16 June 2006

Three readers (so far) have called my attention to errors in “The Semicolon Wars,” my latest American Scientist column.

First, I referred to the programming languages ML, Haskell and Miranda as “pure” functional languages. ML doesn’t belong in that group. Although it is a language that has deep roots in the functional-programming community, ML allows assignment statements that produce side effects, violating any reasonable standard of functional “purity.”

Second, one of the example Lua programs given in the illustration on page 302 is hopelessly confused. As published, the program reads:

function factI (n)
  local accumulator = 1
  for i = 1,n do
    accum = accumulator*i
  end
  return accum
end

The definition should be:

function factI (n)
  local accumulator = 1
  for i = 1,n do
    accumulator = accumulator*i
  end
  return accumulator
end

The story of this goof may be worth telling, at least briefly. I would never trust myself to write even the smallest program correctly without testing the code. In this case I did confirm that the program compiled successfully and gave sensible-looking results, and then I did a copy-and-paste to get the text into the illustration. So what went wrong? In the tested version of the program I named the local variable “accum.” Later, I worried that this abbreviated form might be a bit cryptic to some readers, and so I decided to spell the word out in full. Surely I could make such a trivial change without retesting…?

Mea culpa. And thanks to David Hemmendinger, Steve Christensen and Kirsten Chevalier for their alert reading.

Tags for this article: computing.

Publication history

First publication: 16 June 2006

Converted to Eleventy framework: 22 April 2025

More to read...

AI and the End of Programming

Thesis: People suck at programming computers. Antithesis: Computers are no better at it. Synthesis?

A Shy Woodland Creature

In remembrance of Martin Garner, 1914–2010.

737: The MAX Mess

By all appearances, the rogue behavior of the 737 MAX control system was triggered by a malfunction in a single sensor. That’s not supposed to happen in aviation.

(McCarthyism)

On the death of John McCarthy, the mind behind the Lisp programming language.