PasteRack.org
Paste # 92878
2021-04-25 08:37:50

Fork as a new paste.

Paste viewed 436 times.


Embed:

hmm2

  1. #lang racket/base
  2.  
  3. (require (for-syntax racket/base
  4.                      syntax/parse))
  5.  
  6. (define-syntax (example stx)
  7.   (syntax-parse stx
  8.     #:literals (unquote)
  9.     [(_ (~optional (~seq (~optional #:first-kw) the-first:expr))
  10.         (~optional (~seq (~optional #:second-kw) the-second:expr)))
  11.      #'(hash (~? (~@ 'first the-first)) (~? (~@ 'second the-second)))]))
  12.  
  13.  
  14. (example 5 #:second-kw 6)

=>

'#hash((first . 5) (second . 6))