Does this apply? <a href="http://lists.racket-lang.org/dev/archive/2012-March/009205.html">http://lists.racket-lang.org/dev/archive/2012-March/009205.html</a><span></span><br><br>On Sunday, May 13, 2012, Jens Axel Søgaard wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
I am playing around with the paren-shape syntax property<br>
in order to use {} for polynomials.<br>
<br>
The case {+ p q r ...} is causing me problems.<br>
<br>
I have reduced the problem to the example below.<br>
<br>
I'd like {+ 2 3 5} to expand to (* (* 2 3) 5) and thus evaluate to 30.<br>
However as is {+ 2 3 5} expands to (#%app + (#%app * '2 '3) '5)<br>
which gives 11.<br>
<br>
What have I missed?<br>
<br>
/Jens Axel<br>
<br>
<br>
#lang racket<br>
<br>
(module huh racket<br>
(provide (rename-out [app #%app]))<br>
<br>
(define-for-syntax (curlify stx)<br>
(syntax-property stx 'paren-shape #\{))<br>
<br>
(define-for-syntax (curly? stx)<br>
(let ([p (syntax-property stx 'paren-shape)])<br>
(and p (eqv? p #\{))))<br>
<br>
(define-syntax (app stx)<br>
(syntax-case stx (+)<br>
[{_ + p q}<br>
(curly? stx)<br>
(syntax/loc stx (* p q))]<br>
[{_ + p q r ...}<br>
(curly? stx)<br>
(curlify #'{app + (* p q) r ...})]<br>
[(_ . more)<br>
(syntax/loc stx (#%app . more))])))<br>
<br>
(require 'huh)<br>
{+ 2 3 5}<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote>