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

BOA constructor questions

    Date: Sat, 28 Dec 85 18:02 EST
    From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>

	Date: Thu, 26 Dec 85 16:09 EST
	From: Guy Steele <gls@THINK-AQUINAS.ARPA>


	But this prompts in me another question: does

	(defstruct (foo (:constructor build-foo (&optional baz &aux baz)))
	  (baz 5))

	mean that

	(make-foo)		initializes BAZ to 5
	(make-foo :baz 43)	initializes BAZ to 43
	(build-foo 91)		initializes BAZ to 91
	(build-foo)		*does not initialize* BAZ   ?

	If not, how else can I say it?  (Never mind why I would want to.)

    Isn't this in conflict with your (Guy's) suggested clarification to page 60,
    that a function may not have two parameters with the same name?  If that clarification
    was not intended to apply to &AUX variables, you didn't say so.

Yes, I suppose it is; but then the interpretation of &AUX variables in
this context is completely crocky anyway.  I think I prefer to have the
very simple rule that no duplicate names are permitted within a single
parameter list, period.  One can come up with reasonable interpretations
in many special cases, but such cases are probably all very poor
examples of style.

    The way I read the Common Lisp manual, your example defstruct above does not
    define any function named make-foo.  You'd have to say

	(defstruct (foo (:constructor build-foo (&optional baz &aux baz))
			(:constructor make-foo))
	  (baz 5))

    if you wanted that.

Funny.  I always thought that the normal constructor always gets created
unless explicitly suppressed with (:constructor nil), BOA constructors
being irrelevant to the question.  However, I now find that the prose at
the bottom of page 315 is horribly ambiguous.

    I think the answer to "how else can I say it?" is that you can't say
    it except by being more explicit and verbose, e.g.

	(defstruct (foo (:constructor build-foo (&optional baz))
			(:constructor make-foo (&key (baz 5))))

This sounds fine to me.  This might be awkward if "5" were a very large
expression and I wanted three constructors, two of which initialize slot
BAZ, but I am not going to lose sleep over it.