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

Dylan implementation question



I have a question regarding mandatory keyword defaults; the DRM seems
to contain an inconsistency:

On p. 89, in the second paragraph under Keyword Parameters, we have,
"If no expression is specified, the parameter corresponding to an
unsupplied keyword argument is initialized to #f."

Also, on p. 91, under Types for Keyword Parameters, we have, "If a
keyword parameter is given a type, if #f is not an instance of that
type, and if the keyword parameter is not given a default value, then
the keyword parameter is essentially required."

So far so good. The implication of the above statements is clear: If a
generic function recognizes a keyword, then when the corresponding
method is invoked, the keyword parameter will be bound as follows:

a) If a keyword argument is passed, the keyword parameter will be
bound to the value of the argument.

b) If the keyword argument is not passed, the keyword parameter will
be bound to the value of the keyword's default expression, if any;
otherwise it will be bound to #f.

The net result is that the keyword parameter will always be bound to
something; it will never be unbound.

But now let's look at the definition for the element function, on p.
300: "If no element is associated with key, then the behavior of
element depends on whether it was called with a default argument: if a
default argument was passed, its value is returned; otherwise, an
error is signaled."

Now we have a problem. The specified behavior of element requires that
it knows whether or not a value for default was passed, yet the
keyword parameter binding specification says that a value will
_always_ be bound to default, whether or not a value was explicitly
passed. So how can element tell the difference?

Any enlightenment is welcome.

-Steve Schafer