| Paste number 82939: | curried macros? |
| Pasted by: | hkBst |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1RZV |
| Channel: | #scheme |
| Paste contents: |
Given
((wrap +) macro-to-be-ignored arguments)
I would like to define wrap like so
(define-syntax wrap
(syntax-rules ()
((_ f)
(let-syntax ((ret (syntax-rules ()
((_ c . a)
(f . a)))))
ret))))
but this is invalid. Is there another way I can write wrap? Wrap must be a macro if it is to run before macro-to-be-ignored such that it can throw it away.Annotations for this paste:
| Annotation number 1: | wrap-macro in scheme48 |
| Pasted by: | hkBst |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1RZV/1 |
| Paste contents: |
; $ scheme48 -a batch <<<$'(load "macro-scheme48.scm")'
(define-syntax macro:id
(syntax-rules ()
((_ a) a)))
(define-syntax macro:apply
(syntax-rules (macro:continuation)
((_ (macro:continuation cont) f a ... (l e ...))
(let-syntax ((_cont (syntax-rules ()
((_ (_e (... ...)))
(f (macro:continuation cont) a ... _e (... ...))))))
(l (macro:continuation _cont) e ...)))
((_ f a ... (l e ...))
(let-syntax ((_cont (syntax-rules ()
((_ (_e (... ...)))
(f a ... _e (... ...))))))
(l (macro:continuation _cont) e ...)))))
(define-syntax macro:list
(syntax-rules (macro:continuation)
((_ (macro:continuation cont) e ...)
(cont (e ...)))))
(define-syntax macro:wrap
(syntax-rules ()
((_ f)
(let-syntax ((ret (syntax-rules ()
((_ c . a)
(f . a)))))
ret))))
(define (pretty-print x) (display x) (newline))
(pretty-print (macro:apply + 3 (macro:list 1 2 3)))
(pretty-print (macro:apply (macro:continuation macro:id) (macro:wrap +) 3 (macro:list 1 2 3)))
(pretty-print (apply + 3 (list 1 2 3)))
;==================================
$ scheme48 -a batch <<<$'(load "macro-scheme48.scm")'
macro-scheme48.scm
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: too many ...'s
(... ...)
(&syntax-error)
Warning: too many ...'s
(... ...)
(&syntax-error)
Warning: too many ...'s
(e ...)
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: too many ...'s
(... ...)
(&syntax-error)
Warning: too many ...'s
(... ...)
(&syntax-error)
Warning: too many ...'s
(e ...)
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: segment matching not implemented
(a ... (l e ...))
(&syntax-error)
Warning: invalid expression
(#{Generated l 480} (#{Generated macro:continuation 480} #{Generated _cont 480}) . syntax-error)
(&syntax-error)
Warning: invalid expression
(#{Generated l 482} (#{Generated macro:continuation 482} #{Generated _cont 482}) . syntax-error)
(&syntax-error)
syntax-error
syntax-error
9
#{Unspecific}