www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 74f38a3213310696922fe838f6822ac7d899f8ec
parent a0df96cb3a501e59e3f109a85e9c63a744536b4c
Author: Georges Dupéron <georges.duperon@gmail.com>
Date:   Fri,  3 Feb 2017 09:24:28 +0100

Support for rest arguments to functions with (f . rest), useful for (?@ . blah)

Diffstat:
Mddd-forms.rkt | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ddd-forms.rkt b/ddd-forms.rkt @@ -105,18 +105,19 @@ ;#:with expanded #'(#%app list other) #:with expanded #'other)) (define-syntax-class not-stx-pair - (pattern {~not (_ . _)}))) + (pattern () #:with v #''()) + (pattern {~and v {~not (_ . _)}}))) (define-syntax app (syntax-parser - [{~and (_ fn arg:arg … #;.rest:not-stx-pair) + [{~and (_ fn arg:arg … . rest:not-stx-pair) {~not (_ _ {~literal …} . _)}} ;; not fn directly followed by a … ;#'(#%app apply fn (#%app append arg.expanded …)) (syntax/top-loc this-syntax - (#%app apply fn (#%app splice-append arg.expanded … #;#:rest #;rest)))] - [(_ arg:arg … #;.rest:not-stx-pair) ;; shorthand for list creation + (#%app apply fn (#%app splice-append arg.expanded … #:rest rest.v)))] + [(_ arg:arg … . rest:not-stx-pair) ;; shorthand for list creation ;#'(#%app apply list (#%app append arg.expanded …)) (syntax/top-loc this-syntax - (#%app apply list (#%app splice-append arg.expanded … #;#:rest #;rest)))])) + (#%app apply list (#%app splice-append arg.expanded … #:rest rest.v)))])) (define (splice-append #:rest [rest '()] . l*) (splice-append* (if (null? rest) l* (append l* rest))))