unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#13995: Problem with macros whose expansions define and use auxiliary macros
@ 2013-03-18 23:11 Mark H Weaver
  2013-03-20 12:33 ` Andy Wingo
  2016-06-20 20:22 ` Andy Wingo
  0 siblings, 2 replies; 4+ messages in thread
From: Mark H Weaver @ 2013-03-18 23:11 UTC (permalink / raw)
  To: 13995

Consider the following module:

--8<---------------cut here---------------start------------->8---
(define-module (foo)
  #:export (foo))

(define-syntax-rule (foo bar)
  (begin
    (define-syntax-rule (blah x) x)
    (define (bar val) (blah val))))
--8<---------------cut here---------------end--------------->8---

and the following session with v2.0.7-204-g1ea3762:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use (foo)
scheme@(guile-user)> (foo bar)
scheme@(guile-user)> (bar 5)
ERROR: In procedure #<syntax-transformer blah>:
ERROR: Wrong type to apply: #<syntax-transformer blah>

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 
--8<---------------cut here---------------end--------------->8---

Note that it works when the same 'foo' macro is entered directly
at a fresh REPL:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> 
(define-syntax-rule (foo bar)
  (begin
    (define-syntax-rule (blah x) x)
    (define (bar val) (blah val))))
scheme@(guile-user)> (foo bar)
scheme@(guile-user)> (bar 5)
$1 = 5
scheme@(guile-user)> 
--8<---------------cut here---------------end--------------->8---

       Mark





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13995: Problem with macros whose expansions define and use auxiliary macros
  2013-03-18 23:11 bug#13995: Problem with macros whose expansions define and use auxiliary macros Mark H Weaver
@ 2013-03-20 12:33 ` Andy Wingo
  2013-03-20 17:30   ` Mark H Weaver
  2016-06-20 20:22 ` Andy Wingo
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Wingo @ 2013-03-20 12:33 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: 13995

Have you tried master?
-- 
http://wingolog.org/





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13995: Problem with macros whose expansions define and use auxiliary macros
  2013-03-20 12:33 ` Andy Wingo
@ 2013-03-20 17:30   ` Mark H Weaver
  0 siblings, 0 replies; 4+ messages in thread
From: Mark H Weaver @ 2013-03-20 17:30 UTC (permalink / raw)
  To: Andy Wingo; +Cc: 13995

Andy Wingo <wingo@pobox.com> writes:
> Have you tried master?

I just did, and my toy example works there.  Do you think that commit
de41e56492666801078e73860a358e1c63cbc8c2 is the reason?

It would be nice to get this working in stable-2.0 as well, but I guess
that would require working through our disagreement over the handling of
macro-introduced top-level identifiers.

  http://lists.gnu.org/archive/html/guile-devel/2011-11/msg00016.html

I still strongly believe that we should follow the standard behavior,
namely that each invocation of a macro must introduce fresh identifiers
(even if the macro operands are identical) just as every invocation of a
procedure must introduce fresh lexical variables (even if the procedure
arguments are identical).

    Regards,
      Mark





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#13995: Problem with macros whose expansions define and use auxiliary macros
  2013-03-18 23:11 bug#13995: Problem with macros whose expansions define and use auxiliary macros Mark H Weaver
  2013-03-20 12:33 ` Andy Wingo
@ 2016-06-20 20:22 ` Andy Wingo
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2016-06-20 20:22 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: 13995-done

So, this example works on master, but for reasons you don't like.  We
can't fix it on 2.0.  If you feel that the solution for macro-introduced
identifiers in 2.2 is a release blocker, let's open a thread on -devel
again and talk about it, see if we can find some solutions :)

In the meantime, closing this one, as there's no 2.0 task and the code
"works" in 2.2.

Andy

On Tue 19 Mar 2013 00:11, Mark H Weaver <mhw@netris.org> writes:

> Consider the following module:
>
> (define-module (foo)
>   #:export (foo))
>
> (define-syntax-rule (foo bar)
>   (begin
>     (define-syntax-rule (blah x) x)
>     (define (bar val) (blah val))))
>
> and the following session with v2.0.7-204-g1ea3762:
>
> scheme@(guile-user)> ,use (foo)
> scheme@(guile-user)> (foo bar)
> scheme@(guile-user)> (bar 5)
> ERROR: In procedure #<syntax-transformer blah>:
> ERROR: Wrong type to apply: #<syntax-transformer blah>
>
> Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
> scheme@(guile-user) [1]> 
>
> Note that it works when the same 'foo' macro is entered directly
> at a fresh REPL:
>
> scheme@(guile-user)> 
> (define-syntax-rule (foo bar)
>   (begin
>     (define-syntax-rule (blah x) x)
>     (define (bar val) (blah val))))
> scheme@(guile-user)> (foo bar)
> scheme@(guile-user)> (bar 5)
> $1 = 5
> scheme@(guile-user)> 
>
>        Mark





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-20 20:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18 23:11 bug#13995: Problem with macros whose expansions define and use auxiliary macros Mark H Weaver
2013-03-20 12:33 ` Andy Wingo
2013-03-20 17:30   ` Mark H Weaver
2016-06-20 20:22 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).