diff --git a/collects/honu/core/private/class.rkt b/collects/honu/core/private/class.rkt index 542c1f66f1..89eba7952b 100644 --- a/collects/honu/core/private/class.rkt +++ b/collects/honu/core/private/class.rkt @@ -2,7 +2,7 @@ (require "macro2.rkt" "literals.rkt" - (only-in "honu2.rkt" honu-declaration honu-equal) + (only-in "honu2.rkt" honu-declaration honu-equal separate-ids) (for-syntax racket/base "literals.rkt" "parse2.rkt" @@ -25,11 +25,12 @@ (define-honu-syntax honu-class (lambda (code context) (syntax-parse code #:literal-sets (cruft) - [(_ name (#%parens constructor-argument ...) (#%braces method:honu-class-thing ...) . rest) + [(_ name (#%parens (~var constructor-argument (separate-ids #'honu-comma #'dont-care))) + (#%braces method:honu-class-thing ...) . rest) (define class #'(%racket (define name (class* object% () (super-new) - (init-field constructor-argument ...) + (init-field constructor-argument.id ...) method.result ...)))) (values class #'rest #t)]))) diff --git a/collects/honu/core/private/honu2.rkt b/collects/honu/core/private/honu2.rkt index a011918d59..1d441e8bb7 100644 --- a/collects/honu/core/private/honu2.rkt +++ b/collects/honu/core/private/honu2.rkt @@ -260,15 +260,18 @@ #'more))]))) (begin-for-syntax + (define-splicing-syntax-class (id-must-be what) + [pattern x:id #:when (free-identifier=? #'x what)]) (define-splicing-syntax-class (id-except ignores) - [pattern x:id #:when (not (for/fold ([ok #t]) + [pattern x:id #:when (not (for/fold ([ok #f]) ([ignore ignores]) - (and ok (free-identifier=? #'x ignore))))]) + (or ok (free-identifier=? #'x ignore))))]) + (provide separate-ids) (define-splicing-syntax-class (separate-ids separator end) [pattern (~seq (~var first (id-except (list separator end))) - (~seq (~var between (id-except (list separator end))) + (~seq (~var between (id-must-be separator)) (~var next (id-except (list separator end)))) ...) - #:with (ids ...) #'(first.x next.x ...)])) + #:with (id ...) #'(first.x next.x ...)])) (begin-for-syntax (provide honu-declaration) @@ -285,7 +288,7 @@ #:literals (honu-equal honu-var) [pattern (~seq honu-var (~var variables (separate-ids #'honu-comma #'honu-equal)) honu-equal one:honu-expression) - #:with (name ...) #'(variables.ids ...) + #:with (name ...) #'(variables.id ...) #:with expression #'one.result])) (provide honu-var) diff --git a/collects/tests/honu/class.honu b/collects/tests/honu/class.honu index 9470a6db94..0fb616abd5 100644 --- a/collects/tests/honu/class.honu +++ b/collects/tests/honu/class.honu @@ -1,11 +1,11 @@ #lang honu -class What(x){ +class What(x, y){ var q = 2 foobar(z){ - z + x + z + x + y } }; -var instance = new What(5); +var instance = new What(5, 8); printf("got ~a\n", instance->foobar(10))