Language extension / "behavior"

Duane Rettig duane at franz.com
Wed Jan 25 16:46:47 UTC 2023


--------
    Date:  Wed, 25 Jan 2023 16:00:58 +0100
    From:  Didier Verna <didier at didierverna.net>

    Martin Simmons wrote:
    
    > I think it does, because section 3.5.1.4 Unrecognized Keyword
    > Arguments says that an error must be signaled for unrecognized
    > keywords in a safe call, so that will not happen for an extension
    > keyword.
    
      I'm not sure I understand this. Do you mean that safety declarations
    don't apply to extensions ?

No.  Note that 3.5.1.1 is under 3.5.1, which is "Argument Mismatch Detection".
This applies to _all_functions defined, not just standard functions.
So if I create a function foo with keywords bar and bas, the only way
you can call foo with a :baz keyword withouit getting an error is by
also including :allow-other-keys t (or if the function was originally
defined with &allow-other-keys t).  That applies not only to standard
functions, but to user-defined functions as well.  If in my example
case, I call foo as (foo :baz t) in safe code I get an error, as the
spec requires.

    On the other hand, this section says: "It is not permitted to supply a
    keyword argument to a function using a name that is not recognized by
    that function [...]", but my reading of it is that if an extension
    provides an additional keyword argument, then the function actually
    "recognizes" it, so it seems to me that this section should not apply at
    all.

Yes, as it is really applying to _all_ functions defined with
keywords.

Most CL implementations provide a function that provides you with the
argument list of a function (in Allegro CL it is #'excl:arglist).  With
such a function. most of the time (unless arglist info is stripped
from the lisp or from that function) you can see the argument list of
the function in question and it may include &key in the list, which
will thus tell you what keywords you can use in a conforming manner.

    --=20
    Resistance is futile. You will be jazzimilated.
    
    Lisp, Jazz, A=C3=AFkido: http://www.didierverna.info
--------



More information about the pro mailing list