Subject: Re: defconstant
From: Erik Naggum <erik@naggum.no>
Date: 1995/12/15
Newsgroups: comp.lang.lisp
Message-ID: <19951215T021024Z@arcana.naggum.no>

[Stefan Monnier]

|   Is it possible to use defconstant to define anything else than trivial
|   values?
|   
|   A file such as:
|   
|           (defstruct s a)
|           (defconstant toto (make-s :a 1))
|           
|   is refused by AllegroCL:
|   
|           USER(26): :cl ~/tmp/toto.lisp
|           ; --- Compiling file /users/monnier/tmp/toto.lisp ---
|           ; Compiling MAKE-S
|           ; While compiling (:TOP-LEVEL-FORM "toto.lisp" 2):
|           Error: attempt to call `MAKE-S' which is an undefined function.
|             [condition type: UNDEFINED-FUNCTION]
|   
|   I can work around this by defining toto as a defvar initialized to nil
|   and then set it to some (constant) value inside an init function, but I
|   can't believe defconstant is so limited!

would `eval-when' provide a solution to this problem (i.e., around the
first `defstruct')?  I don't fully understand the CLtL2 or ANSI CL
`eval-when' description, so this is a guess:

    (eval-when (:compile-toplevel :load-toplevel :execute)
      (defstruct s a))
    (defconstant toto (make-s :a 1))

this works with CMUCL 17f, GCL 2.1 and CLISP 1995-08-12, albeit with the
deprecated symbols `compile', `load', and `eval', but I'd like to know if
this is the right way to do it.  comments?

#<Erik 3027982224>
-- 
suppose we actually were immortal...
what is the opposite of living your life as if every day were your last?