From: David Bakhash
Subject: declaring something to be NOT special...
Date: 
Message-ID: <cxjk908lrtq.fsf@engc.bu.edu>
hey,

how, in Lisp, do I specifically declare a variable to be NON-special?
I'm afraid that with ACL, if you leave out the (declare (special ...))
because you specifically don't want that variable to be declared
special, then the compiler assumes it to be, and this may alter the
running of the code.

dave

From: Barry Margolin
Subject: Re: declaring something to be NOT special...
Date: 
Message-ID: <91G92.2$9w2.34@burlma1-snr1.gtei.net>
In article <···············@engc.bu.edu>, David Bakhash  <·····@bu.edu> wrote:
>how, in Lisp, do I specifically declare a variable to be NON-special?
>I'm afraid that with ACL, if you leave out the (declare (special ...))
>because you specifically don't want that variable to be declared
>special, then the compiler assumes it to be, and this may alter the
>running of the code.

It shouldn't.  SPECIAL declarations alter what happens when you make a
binding of the variable.  Implementations only assume a variable is special
when they see a reference that isn't within the scope of a binding of that
variable.  So if you have a binding, it won't be assumed special, and the
right thing should happen.

But perhaps I don't understand what you're getting at.  Could you give an
example of code that you think is valid but would be affected by this?

Note that there *have* been proposals for a LEXICAL declaration, but they
don't address the issue you raise.  IIRC, the intent of them was to prevent
problems if you have a local variable which happens to have the same name
as a special variable -- by using a LEXICAL declaration, you ensure that
your local binding doesn't affect the special variable, e.g.

(setq *print-length* 5)

(let ((*print-length* 2))
  (declare (lexical *print-length*))
  (print '(1 2 3 4 5)))

would print (1 2 3 4 5) rather than (1 2 ...).  However, this proposal was
never adopted (the *var* naming convention and packages generally suffice
to prevent the problem from coming up in practice).

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.
From: David Bakhash
Subject: Re: declaring something to be NOT special...
Date: 
Message-ID: <cxjvhjprc4s.fsf@engc.bu.edu>
I think I understand my confusion now.  thanks.  I just misunderstood
one of the compiler warnings.

thanks, erik, Barry.

dave
From: Erik Naggum
Subject: Re: declaring something to be NOT special...
Date: 
Message-ID: <3121725021809953@naggum.no>
* David Bakhash <·····@bu.edu>
| how, in Lisp, do I specifically declare a variable to be NON-special?

  sorry, there's no (standard) way to do that.  (you might still succeed in
  resetting the flag that makes the compiler believe a symbol has special
  binding -- I've had to do that in a running system.)

| I'm afraid that with ACL, if you leave out the (declare (special ...))
| because you specifically don't want that variable to be declared special,
| then the compiler assumes it to be, and this may alter the running of the
| code.

  this is dead wrong.  what happens if you have an unbound variable in your
  code is that Allegro CL treats it _as_if_ it were declared special, i.e.,
  it _assumes_ it is special for that function (or the smallest enclosing
  lexical scope, actually), it does _not_ declare it special for you.
  here's an example:

CL-USER(33): (compile nil (lambda (x) (+ x y)))
; While compiling (:anonymous-lambda 25):
Warning: Free reference to undeclared variable y assumed special.
#<Function (:anonymous-lambda 25) @ #x20791422>
t
t

  this means that the code goes to look for Y in the dynamic environment as
  it would a special variable.

  (if you can't make this form work because COMPILE barfs on interpreted
  function objects, let me know, and I'll send you a patch I have made that
  has not yet made the official rounds at Franz Inc.)

#:Erik
-- 
  The Microsoft Dating Program -- where do you want to crash tonight?