<HTML><BODY><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 <jarcane@gmail.com>:<br>
<blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
        <div id="">
        



    









        
        


        
        
        

        

        
        

        
        

        
        



<div class="js-helper js-readmsg-msg">
        <style type="text/css"></style>
        <div>
                <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 dir="ltr"><<a href="//e.mail.ru/compose/?mailto=mailto%3aalexander@knauth.org" target="_blank">alexander@knauth.org</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc 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><div><br>
On Dec 8, 2014, at 2:46 AM, J Arcane <<a href="//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></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>
</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>


</div>
</blockquote>
<br>
<br>-- <br>Roman Klochkov<br></BODY></HTML>