GNU bug report logs - #13995
Problem with macros whose expansions define and use auxiliary macros

Previous Next

Package: guile;

Reported by: Mark H Weaver <mhw <at> netris.org>

Date: Mon, 18 Mar 2013 23:14:02 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13995 in the body.
You can then email your comments to 13995 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#13995; Package guile. (Mon, 18 Mar 2013 23:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mark H Weaver <mhw <at> netris.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Mon, 18 Mar 2013 23:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: bug-guile <at> gnu.org
Subject: Problem with macros whose expansions define and use auxiliary macros
Date: Mon, 18 Mar 2013 19:11:17 -0400
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




Information forwarded to bug-guile <at> gnu.org:
bug#13995; Package guile. (Wed, 20 Mar 2013 12:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 13995 <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 13995 <at> debbugs.gnu.org
Subject: Re: bug#13995: Problem with macros whose expansions define and use
	auxiliary macros
Date: Wed, 20 Mar 2013 13:33:31 +0100
Have you tried master?
-- 
http://wingolog.org/




Information forwarded to bug-guile <at> gnu.org:
bug#13995; Package guile. (Wed, 20 Mar 2013 17:33:02 GMT) Full text and rfc822 format available.

Message #11 received at 13995 <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Andy Wingo <wingo <at> pobox.com>
Cc: 13995 <at> debbugs.gnu.org
Subject: Re: bug#13995: Problem with macros whose expansions define and use
	auxiliary macros
Date: Wed, 20 Mar 2013 13:30:05 -0400
Andy Wingo <wingo <at> 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




Reply sent to Andy Wingo <wingo <at> pobox.com>:
You have taken responsibility. (Mon, 20 Jun 2016 20:23:02 GMT) Full text and rfc822 format available.

Notification sent to Mark H Weaver <mhw <at> netris.org>:
bug acknowledged by developer. (Mon, 20 Jun 2016 20:23:02 GMT) Full text and rfc822 format available.

Message #16 received at 13995-done <at> debbugs.gnu.org (full text, mbox):

From: Andy Wingo <wingo <at> pobox.com>
To: Mark H Weaver <mhw <at> netris.org>
Cc: 13995-done <at> debbugs.gnu.org
Subject: Re: bug#13995: Problem with macros whose expansions define and use
 auxiliary macros
Date: Mon, 20 Jun 2016 22:22:00 +0200
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 <at> 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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 19 Jul 2016 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 283 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.