<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Well, I made my own modified version of syntax/parse that lets you define ~separated as a pattern-expander that let’s you do this:</div><div><div><font face="Courier New">#lang racket</font></div><div><font face="Courier New">(require (for-syntax syntax-parse-with-pattern-expanders</font></div><div><font face="Courier New"> (for-syntax racket/base)))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(begin-for-syntax</font></div><div><font face="Courier New"> (define-splicing-syntax-class binding #:literals (=)</font></div><div><font face="Courier New"> [pattern (~seq name:id = expr:expr)])</font></div><div><font face="Courier New"> </font></div><div><font face="Courier New"> (define-syntax ~separated</font></div><div><font face="Courier New"> (pattern-expander</font></div><div><font face="Courier New"> (lambda (stx)</font></div><div><font face="Courier New"> (syntax-case stx ()</font></div><div><font face="Courier New"> [(separated sep pat)</font></div><div><font face="Courier New"> (with-syntax ([ooo '...])</font></div><div><font face="Courier New"> #'((~seq pat (~or (~peek-not _)</font></div><div><font face="Courier New"> (~seq sep (~peek _))))</font></div><div><font face="Courier New"> ooo))]))))</font></div><div><font face="Courier New"> </font></div><div><font face="Courier New"> (define-splicing-syntax-class bindings</font></div><div><font face="Courier New"> [pattern (~separated (~datum /) b:binding)</font></div><div><font face="Courier New"> #:with (name ...) #'(b.name ...)</font></div><div><font face="Courier New"> #:with (expr ...) #'(b.expr ...)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(define-syntax (my-let stx)</font></div><div><font face="Courier New"> (syntax-parse stx</font></div><div><font face="Courier New"> [(_ bs:bindings body)</font></div><div><font face="Courier New"> #'(let ([bs.name bs.expr] ...)</font></div><div><font face="Courier New"> body)]))</font></div><div><font face="Courier New"><br></font></div><div><font face="Courier New">(my-let (x = 1 / y = 2 / z = 3)</font></div><div><font face="Courier New"> (+ x y z))</font></div></div><div><br></div><div>It’s on github here:</div><div><a href="https://github.com/AlexKnauth/syntax-parse-with-pattern-expanders">https://github.com/AlexKnauth/syntax-parse-with-pattern-expanders</a></div><div><br></div><div>I haven’t tested it on anything other than this example though. </div><br><div><div>On Jun 26, 2014, at 3:44 PM, Jens Axel Søgaard <<a href="mailto:jensaxel@soegaard.net">jensaxel@soegaard.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi All,<br><br>The example program below defines a macro, my-let, that<br>enables you to write let-bindings with / as a separator.<br><br> (my-let (x = 1 / y = 2 / z = 3)<br> (+ x y z))<br><br>I'd like to improve the definition of the syntax class called bindings.<br>Ideally I'd like to replace its definition with:<br><br>(begin-for-syntax<br> (define-splicing-syntax-class bindings<br> [pattern (~separated / b:binding)<br> #:with names #'(b.name ...)<br> #:with expressions #'(b.expression ...)]))<br><br>But how can I define the fictitious ~separated ?<br><br>/Jens Axel<br><br><br>#lang racket<br>(require (for-syntax syntax/parse))<br><br>(begin-for-syntax<br> (define-splicing-syntax-class binding #:literals (=)<br> [pattern (~seq name:id = expression:expr)])<br><br> (define-splicing-syntax-class bindings<br> [pattern ()<br> #:with names #'()<br> #:with expressions #'()]<br> [pattern (b:binding)<br> #:with names #'(b.name)<br> #:with expressions #'(b.expression)]<br> [pattern (b:binding (~seq / b*:binding) ...)<br> #:with names #'(b.name b*.name ...)<br> #:with expressions #'(b.expression b*.expression ...)]))<br><br>(define-syntax (my-let stx)<br> (syntax-parse stx<br> [(_ bs:bindings body)<br> (with-syntax ([(name ...) #'bs.names]<br> [(expr ...) #'bs.expressions])<br> #'(let ([name expr] ...)<br> body))]))<br><br>(my-let (x = 1 / y = 2 / z = 3)<br> (+ x y z))<br><br>--<br>Jens Axel Søgaard<br><br>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>