> On Aug 30, 2019, at 1:19 AM, Philip McGrath <phi...@philipmcgrath.com> wrote:
> 
> Hi Kevin,
> 
> This is interesting! A number of people have wanted conveniences around 
> `keyword-apply` and accepting the same keywords as some other function. (The 
> trouble is, different people have different ideas of what those conveniences 
> should be.)
> 
> To start with, I had a few small suggestions about the code you sent: 
> `keyword-apply/filter` doesn't need to be a macro, and your macro should use 
> `fn` rather than `h`;
> the second result of `procedure-keywords` can be `#f` if the given procedure 
> accepts all keywords;
> `for/lists` might be more convenient than `for/fold`;
> I think some of the cases in `filter/kw` get the filtering backwards;
> keywords can be `quote`-ed as values, so you don't need so many 
> symbol-to-string-to-keyword conversions;
> using `set!` this way will cause lots of problems;
> there's no need for `list->vector` in `get-kw-val`; and
> in `def`, it might be better to use syntax parameters than to break hygiene.
> You may know this, but all keyword-accepting functions in Racket are 
> effectively implemented with `make-keyword-procedure`: the variants of 
> `lambda` and `define` that use `kw-formals` are macros that expand to more 
> primitive versions that don't know about keywords. The macros also do some 
> optimization where possible. For inspiration, you might be interested in the 
> implementation in 
> https://github.com/racket/racket/blob/master/racket/collects/racket/private/kw.rkt
>  
> <https://github.com/racket/racket/blob/master/racket/collects/racket/private/kw.rkt>
> 
> For fun, I wrote a version that illustrates some of these suggestions and and 
> tries to do more work at compile-time. Be warned that it is not thoroughly 
> tested! I'm pasting it below, and I've also put it up as a Gist at 
> https://gist.github.com/LiberalArtist/292b6e99421bc76315110a59c0ce2b0d 
> <https://gist.github.com/LiberalArtist/292b6e99421bc76315110a59c0ce2b0d>
> 
> -Philip

Hi Philip,
I’ve been using your kw-pass-through-lambda.rkt module quite happily for a 
while now. One issue I’ve run into though is that the local-keyword-apply 
appears to have an issue when the return is multiple values. For instance, in 
the test module, if you replace the:

  (define (h #:c c . x)
    (list c x))


With:

  (define (h #:c c . x)
    (values c x))

You’ll get an error: “Returned two values to single value return context”

Is there a way to fix this?

Kevin


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/2A70A1D7-741E-4CDF-A29E-49BF1BF14EB7%40gmail.com.

Reply via email to