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

Defstruct default values



    Date: Friday, 30 May 1986  11:43-EDT
    From: preece%ccvaxa at gswd-vms.ARPA (Scott E. Preece)
    To:   COMMON-LISP at su-ai.arpa
    Re:   Defstruct default values

    Maybe I'm missing something, but the book says that the default-init
    is evaluated =each time= a structure is to be constructed [emphasis
    per CLtL].

This is as opposed to being evaluated once at macroexpand time.
Although the manual doesn't say that the default expression isn't
evaluated if the slot value is supplied to the contructor, it seems
pretty pointless to evaluate the default when it isn't used.  Make
that another clarification.

My message was prompted by the discovery that a certain implementation
had taken it upon itself to complain if the default was a constant and
of the wrong type.  Due to the dynamic typing in Common Lisp, it is
not erroneous to have an expression which is type incorrect as long as
the expression is never evaluated.  It is reasonable for a compiler to
warn about such probable type errors, but the defstruct default seems
to me to be a special case, since syntactic bogosity requires people
to specify spurious defaults.

  Rob