<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><base></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Or you don’t even need a syntax-parameter:</div><div><div>#lang racket</div><div>(require (for-syntax syntax/parse))</div><div>(define-syntax letexpand</div><div> (syntax-parser</div><div> [(_ alst body ...)</div><div> (with-syntax ([alst (syntax-local-introduce #`#,(syntax-local-value #'alst))])</div><div> #'(let alst body ...))]))</div><div>(define (foo)</div><div> (define-syntax dave '((is 5) (fat 6)))</div><div> (letexpand dave is fat))</div><div>(foo)</div></div><br><div><div>On Dec 11, 2014, at 6:52 AM, Roman Klochkov <<a href="mailto:kalimehtar@mail.ru">kalimehtar@mail.ru</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><p>#lang racket<br>(require (for-syntax syntax/parse) racket/stxparam)</p><p>(define-syntax letexpand<br> (syntax-parser<br> [(_ alst body ...)<br> (with-syntax ([alst (syntax-local-introduce #`#,(syntax-parameter-value #'alst))])<br> #'(let alst body ...))]))</p><p>(define (foo)<br> (define-syntax-parameter dave '((is 4) (fat 6)))<br> (letexpand dave is fat))</p><p>(foo)</p><br><br><br>Tue, 9 Dec 2014 06:33:14 +0200 от J Arcane <<a href="mailto:jarcane@gmail.com">jarcane@gmail.com</a>>:<br><blockquote style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(8, 87, 166); margin: 10px; padding: 0px 0px 0px 10px;"><div id=""><div class="js-helper js-readmsg-msg"><base target="_self" href="https://e.mail.ru/"><div id="style_14181001540000000605_BODY"><div dir="ltr">Hmm. That does appear to work at a global level, but then when you attempt to use it inside of a function it returns "identifier used out of context". Trying to define-for-syntax in a local context also causes problems; "begin-for-syntax: not in a definition context in: (begin-for-syntax (define-values (z) lst))"</div><div><br><div>On Mon, Dec 8, 2014 at 10:17 PM, Alexander D. Knauth<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="x-msg://e.mail.ru/compose/?mailto=mailto%3aalexander@knauth.org" target="_blank">alexander@knauth.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br><blockquote style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Would something like this work for what you want?<br><br>#lang racket<br>(require (for-syntax syntax/parse))<br>(define-for-syntax dave '((is 5) (fat 6)))<br>(define-syntax letexpand<br> (syntax-parser<br> [(_ alst body ...)<br> (with-syntax ([alst (syntax-local-introduce #`#,(eval-syntax #'alst))])<br> #'(let alst body ...))]))<br>(letexpand dave is fat)<br><div><br>On Dec 8, 2014, at 2:46 AM, J Arcane <<a href="x-msg://e.mail.ru/compose/?mailto=mailto%3ajarcane@gmail.com" target="_blank">jarcane@gmail.com</a>> wrote:<br><br>> I've been experimenting with a new feature for Heresy, and I find myself in need of a macro that can insert the contents of an a-list into a let syntax to serve as its definitions. I am utterly failing to accomplish this. It seems like it should be simple enough to splice a variable's contents into the syntax, and in a sense it is, but not if I want it to actually then evaluate.<br>><br>> For example, I can do this:<br>><br>> (define dave '((is 5) (fat 6)))<br>><br>> (define-syntax letexpand<br>> (syntax-rules ()<br>> [(_ alst body ...)<br>> #`(let #,alst body ...)]))<br>><br>> (letexpand dave is fat)<br>><br>> Which returns a syntax object which looks like what I want:<br>><br>> #<syntax:...:8:7 (let ((is 5) (fat 6)) is fat)><br>><br>> But doesn't actually the evaluate that object. But doing that with merely (let alst body ...) creates an error because rather than splicing alst's contents itself, it merely inserts the variable name given, and then fails because let doesn't recognize it. It will work with a handwritten unquoted alist in that space, but this is largely useless because of course that's what let already basically does anyway.<br>><br>> Am I starting in the wrong place here, and if not, how do I turn that syntax object into something that actually evaluates?<br></div>> ____________________<br>> Racket Users list:<br>> <span class="Apple-converted-space"> </span><a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br><br></blockquote></div><br></div></div><div>____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br><br></div><base target="_self" href="https://e.mail.ru/"></div></div></blockquote><br><br>--<span class="Apple-converted-space"> </span><br>Roman Klochkov</div></blockquote></div><br></body></html>