[racket-dev] weird "module: identifier is already imported" error

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Thu Jun 21 16:41:24 EDT 2012

I can reproduce this error in DrRacket (both with and without debuggging 
enabled) but not in racket. So maybe DrRacket is doing something odd, or 
perhaps there's a bug in module->namespace or something like that.

Ryan


On 06/21/2012 01:52 PM, Christos Dimoulas wrote:
> Hi,
>
> I ran into an error that I can't explain. Do you have any hints about
> what is going on or any suggestions on how to fix it?
>
> In the following code, macros provides alternative forms for require and
> provide, dubbed accept and provide/dispute. They are doing the same job
> as provide and require except that they create a fresh identifier to add
> a little bit of indirection. The first client defines foo and provides
> it with provide/dispute. The other clients just use accept and
> provide/dispute to pass along foo.
>
> When I ran the code I get ''module: identifier is already imported in:
> foo2''.
>
> Thanks.
>
> #lang racket
>
> (module macros racket
>
> (provide accept provide/dispute)
>
> (define-syntax (accept stx)
> (syntax-case stx ()
> [(_ spec id)
> (with-syntax ([(new-id) (generate-temporaries #'(id))])
> #`(begin
> (require (only-in spec [id new-id]))
> (define id new-id)))]))
>
> (define-syntax (provide/dispute stx)
> (syntax-case stx ()
> [(_ id)
> (with-syntax ([(new-id) (generate-temporaries #'(id))])
> #`(begin
> (define new-id id)
> (provide (rename-out [new-id id]))))])))
>
> (module client1 racket
>
> (require (submod ".." macros))
>
> (define (foo x) x)
>
> (provide/dispute foo))
>
> (module client2 racket
>
> (require (submod ".." macros))
>
> (accept (submod ".." client1) foo)
>
> (provide/dispute foo))
>
> (module client3 racket
>
> (require (submod ".." macros))
>
> (accept (submod ".." client2) foo)
>
> (provide/dispute foo))
>
>
> _________________________
> Racket Developers list:
> http://lists.racket-lang.org/dev

Posted on the dev mailing list.