This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about define-syntax


> I just tried the below in the version of Kawa I'm using, and it works
> in the REPL, after you change the define-for-syntax into a plain define.
>

Many-many thanks!
Kawa from SVN head:

#|kawa:1|# (define-for-syntax (make-pair-list stx)
#|(---:2|#   (syntax-case stx ()
#|(---:3|#     (()
#|(---:4|#      (syntax ()))
#|(---:5|#     ((a b . rest)
#|(---:6|#      (with-syntax ((rest-conses (make-pair-list #'rest)))
#|(---:7|#        (syntax
#|(---:8|#         ((cons a b) . rest-conses))))))
#|kawa:9|# (define-syntax func-with-pairs
#|(---:10|#   (lambda (stx)
#|(---:11|#     (syntax-case stx ()
#|(---:12|#       ((_ fn . rest)
#|(---:13|#        (odd? (length (syntax-object->datum #'rest)))
#|(---:14|#        (error "func-with-pairs must have an even number of
arguments"))
#|(---:15|#       ((_ fn . rest)
#|(---:16|#        (with-syntax ((conses (make-pair-list #'rest)))
#|(---:17|#          (syntax
#|(---:18|#           (fn . conses)))))))
#|kawa:19|# (func-with-pairs list 1 2 3 4)
((1 . 2) (3 . 4))
#|kawa:20|#

Many thanks again!

-- 
WBR, Yaroslav Kavenchuk.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]