unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [bug #20941] Modules interact badly with macros
@ 2007-08-31 12:41 Andreas Rottmann
  2007-10-31  0:23 ` Neil Jerram
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rottmann @ 2007-08-31 12:41 UTC (permalink / raw)
  To: Andreas Rottmann, bug-guile


URL:
  <http://savannah.gnu.org/bugs/?20941>

                 Summary: Modules interact badly with macros
                 Project: Guile
            Submitted by: rottmann
            Submitted on: Friday 08/31/2007 at 14:41
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

When a (syntax-rules) macro expands into the use of an internal procedure,
the module the macro resides in must export that internal procedure, which
should not be necessary.

Example session:

guile> (version)
"1.8.2"
guile> (define-module (test) #:export (test-macro) #:use-module (ice-9
syncase)
#<directory (test) b7b2a1d0>
guile> (define (test-proc x) (write x) (newline))
guile> (define-syntax test-macro (syntax-rules () ((test-macro x) (test-proc
(* x x)))))
guile> (define-module (test-user) #:use-module (test))
#<directory (test-user) b7b28ae0>
guile> test-macro
#<macro! sc-macro>
guile> (test-macro 5)

Backtrace:
In standard input:
   9: 0* (test-macro 5)
   9: 1  (test-proc (* 5 5))

standard input:9:1: In expression (test-proc (* 5 5)):
standard input:9:1: Unbound variable: test-proc
ABORT: (unbound-variable)
guile> 


Here is a session with gauche, which gets this right:

gosh> (define-module test
  (export test-macro)
  (define (test-proc x) (write x) (newline))
  (define-syntax test-macro (syntax-rules () ((test-macro x) (test-proc (* x
x))))))
gosh> (import test)
#<undef>
gosh> test-macro
#<macro test-macro>
gosh> (test-macro 5)
25
#<undef>
gosh> 




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?20941>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


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

* [bug #20941] Modules interact badly with macros
  2007-08-31 12:41 [bug #20941] Modules interact badly with macros Andreas Rottmann
@ 2007-10-31  0:23 ` Neil Jerram
  2007-10-31  9:15   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Neil Jerram @ 2007-10-31  0:23 UTC (permalink / raw)
  To: Andreas Rottmann, Neil Jerram, bug-guile


Update of bug #20941 (project guile):

                  Status:                    None => Invalid                

    _______________________________________________________

Follow-up Comment #1:

Is this causing real trouble for you?

From the practical point of view, isn't it straightforward just to export any
procedures that are used by the syntax expansion, as well as exporting the
syntax itself?

From the conformance point of view, there is no case to answer, since R5RS
doesn't specify a module system.

If we in future implement a module or library system according to some
external standard (e.g. R6RS or ERR5RS), and that system specifies that the
procedures should not need exporting, in cases like this, then we will have to
make sure that Guile follows that specification.

For now, however, it seems reasonable just to document that any procedures
used by a syntax expansion must also be exported.

Do you agree?  If you do, I'll look at updating the manual.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?20941>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


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

* [bug #20941] Modules interact badly with macros
  2007-10-31  0:23 ` Neil Jerram
@ 2007-10-31  9:15   ` Ludovic Courtès
  2009-07-20 21:35     ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2007-10-31  9:15 UTC (permalink / raw)
  To: Andreas Rottmann, Ludovic Courtès, Neil Jerram, bug-guile


Follow-up Comment #2, bug #20941 (project guile):

The thing is, for engineering reasons, there are procedures used by macros
that you may not want to export.  Or the macros you export may be using
procedures from other modules that you do not want to re-export.  Overall, you
don't want to pollute the user's name space.

Worse, if the module user uses a renamer or a selector (e.g., "#:select
(the-macro-that-i-want)"), the macros just won't work.

Symbols used by macros should be resolved in the macro definition context,
not in its usage context (see "Composable and Compilable Macros: You Want it
When?" by M. Flatt).

FWIW, I used a hack to make "macros that work" in SRFI-35.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?20941>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.gnu.org/



_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


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

* [bug #20941] Modules interact badly with macros
  2007-10-31  9:15   ` Ludovic Courtès
@ 2009-07-20 21:35     ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2009-07-20 21:35 UTC (permalink / raw)
  To: Andreas Rottmann, Ludovic Courtès, Neil Jerram, bug-guile


Update of bug #20941 (project guile):

             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #3:

The good news is that this is already addressed by the 1.9 development
series.

However, it's very unlikely that it will ever be fixed in the 1.8 series
(fixing it would require a major overhaul of the interpreter, which is does
not appear like a good option given the compiler/VM now available in 1.9.)

Therefore, I'm closing this bug.

Thanks,
Ludo'. 

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?20941>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





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

end of thread, other threads:[~2009-07-20 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-31 12:41 [bug #20941] Modules interact badly with macros Andreas Rottmann
2007-10-31  0:23 ` Neil Jerram
2007-10-31  9:15   ` Ludovic Courtès
2009-07-20 21:35     ` Ludovic Courtès

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).