Subject: Re: weird function behavior
From: Erik Naggum <erik@naggum.net>
Date: Tue, 14 May 2002 21:26:34 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3230400393774701@naggum.net>

* Jacques Wainer
| (defun prob()
|   (let ((x '(nil)))
|     (push 1 (elt x 0))))

  Where did you get the idea that you should use a quoted constant in your
  code to begin with?  I am actually seriously curious about this, because
  it is such an odd and counterintuitive thing to want to do that I am
  looking for some textbook author to blame or something.  If you thought
  it up on yourself, why did you think that a constant was a better choice
  than a freshly created list?  It is not the "don't modify a constant"
  that I wonder why people do not understand, it is their initial desire to
  use a constant in the first place that puzzles me.  What core concept do
  you have to have missed in order to believe that a constant is a suitable
  thing to specify when you know you are going to modify some part of it?

  A very weak conjecture on my part goes like this: People are used to
  programs that load fresh into a pristine environment where they can wreak
  havoc with constants and terminate wihout causing observable problems.
  There is no corrector to the abuse of these constants and because most
  programming languages make it easier to write constants than freshly
  created objects, the idea that using a constant could be an error does
  not arise consciously.  So when using a constant does not work, the
  _last_ thing they would think about is that the constant that is being
  modified actually _survives_ between what they are certain are fresh
  instantiations in a pristine environment.

  If my weak conjecture has merit, the solution to this problem is not to
  ask people to stop modifying constants, it is to teach people more about
  the execution models of computers, operating systems, and languages.
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.

  70 percent of American adults do not understand the scientific process.