From: Paul F. Dietz
Subject: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <OWadnbbEkd4A2jqjXTWcqg@dls.net>
According to section 7.1.2 of the CLHS,

    The set of valid initialization arguments for a class is
    the set of valid initialization arguments that either fill slots
    or supply arguments to methods, along with the predefined
    initialization argument :allow-other-keys. The default value
    for :allow-other-keys is nil.

According to section 7.1.3,

    The initialization arguments supplied to make-instance are
    combined with defaulted initialization arguments to produce
    a defaulted initialization argument list. A defaulted initialization
    argument list is a list of alternating initialization argument names
    and values in which unsupplied initialization arguments are defaulted
    and in which the explicitly supplied initialization arguments appear
    earlier in the list than the defaulted initialization arguments.

 From this, I deduce that :allow-other-keys nil is placed into the
defaulting initialization argument list unless :allow-other-keys is
already supplied in the initialization list.  So this behavior should
be expected:

(defclass foo ()
    ((s :initarg :allow-other-keys)))

(slot-value (make-instance 'foo) 's) ==> nil  ;; instead of being unbound

Alas, in all the implementations I've tried this in the slot is unbound.
Am I wrong?

	Paul

From: Steven M. Haflich
Subject: Re: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <3EA81D1C.8050301@alum.mit.edu>
Paul F. Dietz wrote:

>  From this, I deduce that :allow-other-keys nil is placed into the
> defaulting initialization argument list unless :allow-other-keys is
> already supplied in the initialization list.  So this behavior should
> be expected:

In the following example, the default value of pie is 22/7, but would
you similarly expect the keyword and defaulted value to be added somehow
to the rest list?

   <49> (defmethod foo (&rest rest &key (pie 22/7))
          (declare (ignore rest)) pie)
   #<standard-method foo nil>
   <50> (defmethod foo :around (&rest rest)
          (print rest)
          (call-next-method))
   #<standard-method foo :around nil>
   <51> (foo)

   nil
   22/7

:allow-other-keys is not an "initialization argument" in the sense
of the cited paragraphs.  What it means is this:

   <56> (defclass foo ()
          ((a :initform 22/7 :initarg :a)
           (b :initarg :b))
          (:default-initargs :b 3.1))
   #<standard-class foo>
   <57> (defmethod initialize-instance :around ((x foo) &rest initargs)
          (print initargs))
   #<standard-method initialize-instance :around (foo)>
   <58> (make-instance 'foo)

   (:b 3.1)
   #<foo @ #x71e772ea>
From: Paul F. Dietz
Subject: Re: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <MA2dnSPq0eZYFzWjXTWcog@dls.net>
Steven M. Haflich wrote:


> :allow-other-keys is not an "initialization argument" in the sense
> of the cited paragraphs.  What it means is this:

In this example it sure was!  It was specified as the :initarg for
the slot.


>   <56> (defclass foo ()
>          ((a :initform 22/7 :initarg :a)
>           (b :initarg :b))
>          (:default-initargs :b 3.1))
>   #<standard-class foo>
>   <57> (defmethod initialize-instance :around ((x foo) &rest initargs)
>          (print initargs))
>   #<standard-method initialize-instance :around (foo)>
>   <58> (make-instance 'foo)

INITIALIZE-INSTANCE is passed the *defaulted* initialization argument
list, not the initialize argument list that is passed to MAKE-INSTANCE.
MAKE-INSTANCE fills it out with the appropriate default values.

So the question is, does the NIL that is specified as the default
value of the initialization argument :allowed-other-keys (in section 7.1.2)
qualify as a default that causes the initialization argument to become
a defaulted initialization argument?  If not, why not?

	Paul
From: Paul F. Dietz
Subject: Re: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <5wSdnYEVvJakEDWjXTWcrg@dls.net>
I wrote:

> value of the initialization argument :allowed-other-keys (in section 7.1.2)

(fix typo)

	Paul
From: james anderson
Subject: Re: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <3EA91379.80DCCD6E@setf.de>
one reading is that 7.1.2 specifies an aspect of the effective method's
signature, while 7.1/7.1.3 describe the the content of the initialization
argument list.

the descriptions of how the initialization argument list is constructed do not
read as if they require that a symbol/value pair be added for
:allow-other-keys. neither does the description of how valid initialization
arguments are established. neither does the description of how values are defaulted.

just as reasonable as the implicit

(defclass standard-object ()
	()
	(:default-initargs :allow-other-keys nil))

would be to implicitly augment the method signatures

(defmethod x (&key) ) -> (defmethod x (&key (allow-other-keys nil)))

"Paul F. Dietz" wrote:
> 
> Steven M. Haflich wrote:
> 
> > :allow-other-keys is not an "initialization argument" in the sense
> > of the cited paragraphs.  What it means is this:
> 
> In this example it sure was!  It was specified as the :initarg for
> the slot.
> 
> >   <56> (defclass foo ()
> >          ((a :initform 22/7 :initarg :a)
> >           (b :initarg :b))
> >          (:default-initargs :b 3.1))
> >   #<standard-class foo>
> >   <57> (defmethod initialize-instance :around ((x foo) &rest initargs)
> >          (print initargs))
> >   #<standard-method initialize-instance :around (foo)>
> >   <58> (make-instance 'foo)
> 
> INITIALIZE-INSTANCE is passed the *defaulted* initialization argument
> list, not the initialize argument list that is passed to MAKE-INSTANCE.
> MAKE-INSTANCE fills it out with the appropriate default values.
> 

"defaulted value forms for initialization arguments are defined by using the
:default-initargs class option to defclass"

> So the question is, does the NIL that is specified as the default
> value of the initialization argument :allowed-other-keys (in section 7.1.2)
> qualify as a default that causes the initialization argument to become
> a defaulted initialization argument?  If not, why not?

7.1.2 applies to making, re-initializing, and updating while the
:default-initargs specification applies to making an instance only.

...
From: Paul F. Dietz
Subject: Re: initialization argument lists and :allow-other-keys
Date: 
Message-ID: <CMqdnTOvKNxpgjSjXTWcrg@dls.net>
james anderson wrote:

> "defaulted value forms for initialization arguments are defined by using the
> :default-initargs class option to defclass"

Ok, that seems definitive.  Thanks.
	
	Paul