chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] inline-syntax and require-extension-for-sy


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] inline-syntax and require-extension-for-syntax
Date: Sun, 12 May 2013 23:17:47 +0200
User-agent: Mutt/1.4.2.3i

On Sun, May 12, 2013 at 10:49:09PM +0200, Felix wrote:
> Attached are some patches for adding two small enhancements:
> 
> 1) "require-extension-for-syntax"/"use-for-syntax", which does
>    the same as the often occurring idiom
> 
>      (begin-for-syntax (require-library FOO))
>      (import-for-syntax FOO)
> 
>    So this loads an extension and imports it, but at expansion time.

This looks very useful.  I'll take a closer look tomorrow.

> 2) "inline-syntax": allows "anonymous" macro expansions, i.e. 
>    an expansion without an intermediate macro:
> 
>      ;; (a use for use-for-syntax, BTW)
>      (define nums
>        (inline-syntax
>          (lambda (r c) 
>          `(,(r 'quote) ,@(iota 10000)))))

This looks wrong to me.  Firstly, there's no way to use other macro
transformers than explicit renaming.  Implicit renaming would be
good to have here too.

Secondly, and more importantly, there's a strip-syntax call in the
implementation, which I *think* will mean that it will be unusable
inside other macro expanders (inside a let-syntax, for example).
If this is to be added to core, I think a lot of test cases will need
to be added as well, because this stuff is just too easy to get wrong.

Finally, what's wrong with the following?

(define nums
  (let-syntax ((foo (er-macro-transformer
                      (lambda (e r c)
                        `(,(r 'quote) ,(iota 10000))))))
    (foo)))

It's only 1 line longer (granted, it's more characters to type), and it
allows for choosing your expander.

I believe a better place for "inline-syntax" is the miscmacros egg.
There's no technical reason this needs to be added to core, as it's
purely an extension of what we already have.

Cheers,
Peter
-- 
http://www.more-magic.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]