Re: Is DEFCONSTANT broken?



On Jun 23, 2:40 pm, Scott Burson <FSet....@xxxxxxxxx> wrote:
On Jun 22, 6:46 pm, Ron Garret <rNOSPA...@xxxxxxxxxxx> wrote:

In article <20090704083602....@xxxxxxxxx>,
 Kaz Kylheku <kkylh...@xxxxxxxxx> wrote:

  (eval-when (:load-toplevel)
    (define-symbol-macro c7 (c7)))

See: two different definitions for diferent situations, creating the
illusion of one consistent constant.

That works insofar as (eq c7 (c7)) returns T.  However, it's not really
what I want.  The main reason I want to use DEFCONSTANT is to prevent c7
from being reassigned or rebound.  If C7 is a symbol macro I don't get
that guarantee.  If I were willing to rely on the user not to assign or
bind c7 I could just use DEFVAR and be done with it.

Yeah, oh well.

To address your larger point, yes, I have long thought DEFCONSTANT is
not as useful as its inventor(s) probably hoped.

That's because you're thinking of defconstant as providing some sort
of "protection", which it does not. In fact, CL as a whole is an open
language which relies on the goodwill of the programmer to ensure that
things don't get mashed. If you want a language that provides you
with guarantees of bondage, CL is not the language for you, and due to
those of us who enjoy the freedom (I'm sure you're also one of them)
it's not likely to change in that direction.

Duane
.



Relevant Pages

  • Re: Is DEFCONSTANT broken?
    ... | The main reason I want to use DEFCONSTANT is to prevent c7 from being ... | reassigned or rebound. ... supposed to be the programmable programming language? ...
    (comp.lang.lisp)
  • Re: Is DEFCONSTANT broken?
    ... illusion of one consistent constant. ...  The main reason I want to use DEFCONSTANT is to prevent c7 ... from being reassigned or rebound. ... To address your larger point, yes, I have long thought DEFCONSTANT is ...
    (comp.lang.lisp)