[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

defconstant/defclass problem

    Date: Fri, 18 Sep 1992 15:18 EDT
    From: Philip L. Stubblefield <phil@rpal.rockwell.com>

    Using Genera 8.1.1 on a MacIvory III, we're having an unexpected problem
    compiling a file that uses a constant as the initform for a slot.  When you try
    to compile this file (listed below), the compiler complains that the variable
    FOO is unbound.  Because the compiler needs to know the value of a constant in
    order to open-code it, I had always assumed that the compiler bound the constant
    at compile time, but this appears not to be the case.  What gives?  This seems
    like a bug to us.

    ;;; -*- Mode: LISP; Syntax: Ansi-common-lisp; Package: CL-USER; Base: 10 -*-

    (defconstant foo 0)

    (defclass bar ()
      ((baz :initform foo)))

I don't get any error from this using 8.1.1 on a 3650.  If it's really
happening, I agree that it's a bug, although your reasoning about the
compiler assigning the variable at compile time is incorrect.  The
compiler remembers what the constant would be bound to and open-codes it
that way, but it doesn't do so by doing a real variable assignment in
the compiler's execution environment.  But this is orthogonal to the
bug, since the init form isn't supposed to be evaluated at compile time
in the first place, so it shouldn't matter; the dpANS CL description of
the :INITFORM slot option specifically says, "For local slots, the
dynamic environment is the dynamic environment in which MAKE-INSTANCE is
called", which is not the compile-time environment.