You can use it with keyword-apply

(define (foo #:x x) (+ x 3))
(keyword-apply foo (list (string->keyword "x")) (list 8) '())
;; ==> 11

http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._keyword-apply%29%29

On Mon, Jan 9, 2017 at 12:47 PM, David Storrs <david.sto...@gmail.com>
wrote:

> What should string->keyword be used for?  I was expecting this to work
> but it does not:
>
> (define (foo #:x x) (+ x 3))
>
> (foo (string->keyword "x") 8)
>
> ; foo: arity mismatch;
> ;  the expected number of arguments does not match the given number
> ;   expected: 0 plus an argument with keyword #:x
> ;   given: 2
> ; [,bt for context]
>
>
> I know I can do this with a macro, but I was hoping it could happen
> more straightforwardly at runtime.
>
> --
> 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.
>

-- 
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