From: ·············@gmail.com
Subject: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <1182271559.463927.27940@m36g2000hse.googlegroups.com>
Hi,

Here is a real newbie question. I accidentally defined a named
constant with defconstant and now need to undefine it. Is there any
easy way to do this?

BTW, I am using sbcl...

DI

From: D Herring
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <R6GdnWb_m7zsjeXbnZ2dnUVZ_s_inZ2d@comcast.com>
·············@gmail.com wrote:
> Hi,
> 
> Here is a real newbie question. I accidentally defined a named
> constant with defconstant and now need to undefine it. Is there any
> easy way to do this?
> 
> BTW, I am using sbcl...
> 
> DI
> 

(defconstant abc 1)
abc => 1
(unintern 'abc)
abc => error
From: Ari Johnson
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <m2sl8nq269.fsf@hermes.theari.com>
D Herring <········@at.tentpost.dot.com> writes:

> ·············@gmail.com wrote:
>> Hi,
>>
>> Here is a real newbie question. I accidentally defined a named
>> constant with defconstant and now need to undefine it. Is there any
>> easy way to do this?
>>
>> BTW, I am using sbcl...
>>
>> DI
>>
>
> (defconstant abc 1)
> abc => 1
> (unintern 'abc)
> abc => error

SBCL:

* (defconstant abc 1)

ABC
* (unintern 'abc)

T
* abc

debugger invoked on a UNBOUND-VARIABLE in thread #<THREAD "initial thread" {100255A9A1}>:
  The variable ABC is unbound.
From: Pascal Bourguignon
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <87d4zrswn3.fsf@thalassa.lan.informatimago.com>
·············@gmail.com writes:
> Here is a real newbie question. I accidentally defined a named
> constant with defconstant and now need to undefine it. Is there any
> easy way to do this?
>
> BTW, I am using sbcl...

(unintern '+name-of-the-constant+)

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: ·············@gmail.com
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <1182275893.438882.185490@m36g2000hse.googlegroups.com>
On Jun 19, 1:05 pm, Pascal Bourguignon <····@informatimago.com> wrote:
> ·············@gmail.com writes:
> > Here is a real newbie question. I accidentally defined a named
> > constant with defconstant and now need to undefine it. Is there any
> > easy way to do this?
>
> > BTW, I am using sbcl...
>
> (unintern '+name-of-the-constant+)

That's the first thing I tried... And it didn't work.
I also tried (makunbound '+name-of-the-constant+) and that didn't work
either...
From: ·············@gmail.com
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <1182276214.995834.53540@c77g2000hse.googlegroups.com>
On Jun 19, 1:58 pm, ·············@gmail.com wrote:
> On Jun 19, 1:05 pm, Pascal Bourguignon <····@informatimago.com> wrote:
>
> > ·············@gmail.com writes:
> > > Here is a real newbie question. I accidentally defined a named
> > > constant with defconstant and now need to undefine it. Is there any
> > > easy way to do this?
>
> > > BTW, I am using sbcl...
>
> > (unintern '+name-of-the-constant+)
>
> That's the first thing I tried... And it didn't work.
> I also tried (makunbound '+name-of-the-constant+) and that didn't work
> either...


OOPS, sorry

(unintern 'name-of-the-constant (find-package :package-name))

*does* work. I was previously trying

(unintern 'package-name::name-of-the-constant)

and that wasn't working for obvious reasons. I had forgotten about
having to find the package. Sorry for the confusion and thanks.
From: Steven Haflich
Subject: Re: How do you undefine a named constant in common lisp?
Date: 
Message-ID: <v22ei.5239$bP5.2882@newssvr19.news.prodigy.net>
·············@gmail.com wrote:
> OOPS, sorry
> 
> (unintern 'name-of-the-constant (find-package :package-name))
> 
> *does* work.

No. it doesn't work, although it may do what you want.

I hope all the other kind respondents haven't confused the
matter too badly, but in ANSI CL variable constantness is
tied to a symbol object, and there is no portable way to
remove constantness.  What everyone has been puttering
around with is changing which symbol is resolved by the
reader (and by find-symbol and intern) when given the
symbol nme of the original constant symbol.  That is a very
different thing.

The dribble appended below illustrates this, and I expect
you already understand it.  The important point is that the
unintern trick to remove a constant (or replace a flawed
definition of a generic function, or replace a bogus type
definition, etc. etc. etc.) only works if any source that
was read while the old symbol was defined will need to be
reread so that the new symbol is resolved by the new source.

cl-user(2): (defparameter *pie-symbol*
		(defconstant *pie* 22/7))
*pie-symbol*
cl-user(3): (defparameter *pie-source*
		'(defun pie () (symbol-value '*pie*)))
*pie-source*
cl-user(4): (eval *pie-source*)
pie
cl-user(5): (pie)
22/7
cl-user(6): (unintern *pie-symbol*)
t
cl-user(7): *pie-source*
(defun pie () (symbol-value '#:*pie*))
cl-user(8): (constantp *pie-symbol*)
t
cl-user(9): (defconstant *pie* pi)
*pie*
cl-user(10): (pie)
22/7
cl-user(11): (defun pie () (symbol-value '*pie*))
pie
cl-user(12): (pie)
3.141592653589793d0
cl-user(13): (eq '*pie* *pie-symbol*)
nil
cl-user(14): (pprint *pie-source*)

(defun pie () (symbol-value '#:*pie*))