[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Dealias module names in saved module import fo
From: |
Evan Hanson |
Subject: |
[Chicken-hackers] [PATCH] Dealias module names in saved module import forms |
Date: |
Sun, 19 Oct 2014 00:19:48 -0700 |
User-agent: |
OpenSMTPD enqueuer (Demoosh) |
Hi all,
The attached patch fixes #1149.
The basic problem is that import libraries for modules created by
functor instantiation refer to their imports by the functor's parameter
names rather than real names of the modules it's passed as arguments.
(See Juergen's original description of the bug from last year, below.)
To fix this, module imports need to be dealiased as they're saved to the
current module during expansion. This ensures that real module names are
used in the resulting import library.
Thanks for the wonderfully clear report, Juergen.
Cheers,
Evan
On 2014-08-13 13:37, Juergen Lorenz wrote:
> Hi all,
>
> I've found a bug in the functor implementation.
> Consider the following trivial example
>
> ;;; doubling-functor.scm
> ;;; --------------------
>
> ;;; compile-with csc -s doubling-functor.scm -J
> ;;; csc -s doubling-functor.import.scm
>
> ;;; defining the functor
> (functor (doubling-functor
> ;; parameter module with its exports
> (M (add)))
> ;; exports of doubling-functor
> (doubling)
> ;; body of doubling-functor
> (import scheme M)
> (define (doubling x) (add x x)))
>
> ;;; num-doubler.scm
> ;;; ---------------
>
> (import doubling-functor)
>
> ;;; parameter module defining add
> (module nums (add)
> (import scheme)
> (define (add x y) (+ x y)))
>
> ;; instantiating doubling-functor by applying it to concrete argument
> ;; modules
>
> (module num-doubler = (doubling-functor nums))
>
> ;;;; or -- in short form
> ;(module num-doubler = doubling-functor
> ; (import scheme)
> ; (define (add x y) (+ x y)))
>
> ;;; end of file
>
> Everything works fine in interpreted mode. Compiling doubling-functor.scm
> works as well. But if you compile num-doubler
>
> csc -s num-doubler.scm -J
> csc -s nums.import.scm
> csc -s num-doubler.import.scm
>
> the last call will fail. The reason is the line
>
> (eval '(import scheme M))
>
> of the chicken generated file num-doubler.import.scm.
> Of course, M should be replaced by nums (or _num-doubler in the short
> form). After this change, compiling and using works well.
>
> Cheers
>
> Juergen
>
> --
>
> Dr. Juergen Lorenz
> Flensburger Str. 12
> 10557 Berlin
0001-Dealias-module-names-in-saved-module-import-forms.patch
Description: Text document
- [Chicken-hackers] [PATCH] Dealias module names in saved module import forms,
Evan Hanson <=