On Dec 17, 2012, at 10:51 PM, Haiwei Zhou wrote:

> Hi,
> 
>   I am writing some code with json. Request may look likes (hasheq 'action 
> "doit" 'arg1 "a" 'arg2 "b"). 
> 
>   Is there any function or library which can apply a proc with hasheq? The 
> expected result is (proc #:action "doit" #:arg1 "a" #:args "b")?

I think the easiest way to do this would be to use "match" inside the body of 
the procedure being defined. So:

(define (hashy-proc ht)
  (match ht
    [(hash-table ("action" a) ("arg1" a1) ("arg2" a2))
      ... code that uses a and a1 and a2 ...])


If this is too verbose for you, you could hide it using a macro, so that it 
looks like

(define-hashproc (proc #:action a #:arg1 a1 #:arg2)
  ... code that uses a and a1 and a2...)


... but I would try it first with the first form, to see whether you can live 
with it.


That's my thought, anyhow.

John Clements

Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to