Subject: Re: beginner question
From: Erik Naggum <>
Date: 1998/04/28
Newsgroups: comp.lang.lisp
Message-ID: <>

* Rob Warnock
| But that really wasn't the quesion I was asking! To rephrase it in the
| context of your example, suppose when you write the code you give, there's
| *already* a top-level variable named "line-counter" -- which, as several
| people have answered me, is necessarily "special" (dynamic). So now instead
| of getting a new lexical variable "line-counter" for your functions "foo" &
| "bar" to share privately, you have perturbed the value of the global dynamic
| variable "line-counter", and if either "foo" or "bar" calls a function that
| uses "line-counter", unexpectedness will happen... (Won't it?)

  if you don't stick to the very good convention to use asterisks around
  special variables, the expected unexpectedness will happen.  that's why
  you _always_ want to use asterisks around special variables.  there is no
  (declare (nospecial ...)), unfortunately.  (I think there should be.)

| As someone else pointed out, the way you do what you want in Scheme is:
| 	(define foo #f)
| 	(define bar #f)
| 	(let ((line-counter 0))
| 	  (set! foo (lambda (...) ...))
| 	  (set! bar (lambda (...) ...)))
| (which is basically identical to the usual expansion of "letrec"...)

  let's see some elegant syntax for it, now that you have DEFINE-SYNTAX to
  play with, and I'll perhaps modify my statement.  the above (the use of
  internal vs top-level DEFINE in general, actually) is such a horribly
  klutzy way of doing things that my knee-jerk reaction is "inelegant by
  design".  Schemers don't think so -- they have already decided that
  Scheme is elegant, and that this is "necessary", although they keep
  arguing that "necessary" translates to "inelegant" in Common Lisp.  I
  find it moderately amusing to tease Schemers with instances like this.

  Abort, Retry, or Upgrade?