scsh-users
[Top] [All Lists]

Modules shadowing bug.

To: scsh-news@zurich.ai.mit.edu
Subject: Modules shadowing bug.
From: Breanndán Ó Nualláin <bon@illc.uva.nl>
Date: 06 Jun 2003 12:25:15 +0200
Organization: Faculty of Science, University of Amsterdam
Either there's a bug in module shadowing or else there's a bug in my
understanding of module shadowing.  I'd quite like to know which one.
It pertains to shadowing of the MEMBER procedure by SRFI-1 isolated in
this snippet:

    (define-structure s-foo
      (export (foo :syntax))
      (open scheme srfi-1)
      (begin
    
        (define-syntax foo
          (syntax-rules ()
            ((foo x) (member x '(1 2 3) =))))))
    
I expect expansions of foo to contain the SRFI-1 extension of MEMBER
which can take an equality predicate as an optional third argument.
However the expansion grabs the MEMBER from scheme-level-1:

    $ scsh -lm s.scm
    Welcome to scsh 0.6.4 (Olin Shivers)
    Type ,? for help.
    > ,open s-foo
    Load structure s-foo (y/n)? y
    [s-foo]
    > (foo 2)
    
    Warning: wrong number of arguments
             (member 2 '(1 2 3) =)
             (procedure wants: (:value :value))
             (arguments are: (:exact-integer :pair (proc (:real :real &rest 
:real) :boolean)))
    
    Error: wrong number of arguments
           ('#{Procedure 621 (unnamed in mem in scheme-level-1)} 2 '(1 2 3) 
'#{Procedure 66 (= in scheme-level-0)})
    1>              



One workaround is to rename MEMBER on opening SRFI-1:

    (define-structure s-foo
      (export (foo :syntax))
      (open scheme
            (modify srfi-1 
                    (rename (member foo-member))))
      (begin
    
        (define-syntax foo
          (syntax-rules ()
            ((foo x) (foo-member x '(1 2 3) =))))))

Now we get:

    $ scsh -lm s.scm
    Welcome to scsh 0.6.4 (Olin Shivers)
    Type ,? for help.
    > ,open s-foo
    Load structure s-foo (y/n)? y
    [s-foo]
    > (foo 2)
    '(2 3)
    > 


<Prev in Thread] Current Thread [Next in Thread>