On 8/4/2018 7:24 AM, Philip McGrath wrote:
On Sat, Aug 4, 2018 at 5:26 AM, George Neuner <gneun...@comcast.net <mailto:gneun...@comcast.net>> wrote:

    On Sat, 4 Aug 2018 00:08:46 -0500, Philip McGrath
    <phi...@philipmcgrath.com <mailto:phi...@philipmcgrath.com>> wrote:

    >and you can create a function that accepts arbitrary or
    >dynamically-calculated keyword arguments (which is rarely
    desirable) using
    >make-keyword-procedure

    But this creates a procedure that accepts anything.  This seems worse
    than the solution using the plist: the keyword accepting variant of
    the function can't have named positional arguments.


Actually, the function passed to `make-keyword-procedure` can have required and/or optional named positional arguments. You can use `procedure-reduce-keyword-arity` to further specialize what arguments the resulting function requires and/or accepts.

Ok, but it's really confusing ... the more so because there isn't a relevant example in the docs.  The signature:

     (((listofkeyword?)list?)()#:restlist?. ->*.any)

doesn't readily indicate to me that additional arguments are possible.  Playing with it, it seems that the function in fact can have its own positional arguments, but the 1st and 2nd arguments always will receive the keyword and keyarg lists - the function's own positional arguments (if any) must begin with the 3rd argument.

Whether this is a doc issue or an issue with my brain is a toss up.  If that empty list in the signature is meant to represent the function's own arguments, I'd have expected some indication of that: something like  (listof name)?, or (formals*), or something instead of ().

Racket's built-in keyword argument system is fully dynamic (though admittedly not always convenient to use dynamically out of the box), but it also provides great support for the common case where the keywords to be applied are statically visible, which an ad-hoc symbols-as-"keywords" system can't.

It's the uncommon cases that are interesting.  I'm going to have to play much more with it.  Thank you for the examples - I'm trying to understand them.

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to