私のプログラムには複数のモジュールがあります。例えば。モジュールfoo
およびモジュールbar
。モジュールfoo
は、モジュールbar
を参照します。次に、私はcsi(解釈された)replでそれらのモジュールをテストできるようにしたいと思います。この質問の根源は、コードをコンパイルしなければならない場合です。以下は私の例です。複数のモジュールを解釈する
注:私は初心者ですので、このコードには他の問題がある可能性があります。自由に何かを指摘してください。私は修正しようとします。
foo.scm
(use r7rs)
(define-library (foo)
(import (scheme base)
(prefix bar bar:))
(export add-some-stuff)
(begin
(define baz 1)
(define (add-some-stuff)
(+ baz bar:bork))
))
bar.scm
(use r7rs)
(define-library (bar)
(import (scheme base))
(export bork)
(begin
(define bork 2)))
結果があることを望んでいるだろう:
$ csi
> ,l foo.scm
> (import (prefix foo foo:))
> (foo:add-some-stuff)
;;=> 3
ここに私が取得エラーです:
は$ csi -q
#;1> ,l foo.scm
; loading foo.scm ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/chicken.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/numbers.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/foreign.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/srfi-4.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/scheme.base.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs-support.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/extras.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/srfi-13.import.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs-compile-time.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs-library.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs-support.so ...
Note: re-importing already imported syntax: syntax-rules
Note: re-importing already imported syntax: cond-expand
Note: re-importing already imported syntax: define-record-type
Note: re-importing already imported syntax: include
Note: re-importing already imported syntax: include
Note: re-importing already imported syntax: import
Note: re-importing already imported syntax: import-for-syntax
Note: re-importing already imported syntax: cond-expand
Note: re-importing already imported syntax: import-for-syntax
Note: re-importing already imported syntax: import
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/r7rs.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/numbers.so ...
; loading /usr/local/Cellar/chicken/4.12.0/lib/chicken/8/scheme.base.so ...
Note: re-importing already imported syntax: syntax-rules
Note: re-importing already imported syntax: import-for-syntax
Note: re-importing already imported syntax: import
Note: re-importing already imported syntax: cond-expand
Note: re-importing already imported syntax: import-for-syntax
Note: re-importing already imported syntax: import
Error: (import) during expansion of (import ...) - cannot import from undefined module: bar
Call history:
numbers.scm:1672: scan-real
<syntax> (define-library (foo) (import (scheme base) (prefix bar bar:)) (export add-some-stuff) (begin (defin...
<syntax> (##core#module foo ((##r7rs#foo)) (##core#define-syntax ##r7rs#foo (##core#lambda _ (quote (##core#u...
<syntax> (##core#define-syntax ##r7rs#foo (##core#lambda _ (quote (##core#undefined))))
<syntax> (##core#lambda _ (quote (##core#undefined)))
<syntax> (##core#begin (##core#quote (##core#undefined)))
<syntax> (##core#quote (##core#undefined))
<syntax> (##core#undefined)
<syntax> (##sys#provide (##core#quote foo))
<syntax> (##core#quote foo)
<syntax> (import-for-syntax (only r7rs begin cond-expand export import import-for-syntax include include-ci s...
<syntax> (##core#undefined)
<syntax> (import (only r7rs begin cond-expand export import import-for-syntax include include-ci syntax-rules...
<syntax> (##core#undefined)
<syntax> (##core#begin (import (scheme base) (prefix bar bar:)) (##core#begin (export add-some-stuff) (##core...
<syntax> (import (scheme base) (prefix bar bar:)) <--
#;1>
感謝を結果です!私の質問の根源は、コンパイルせずにプロジェクトのコード上でインタプリタを使用できるかどうかということです。それは私ができないように見えるが、それはまだ決定的ではないかもしれない。私は私の例で他のエラーを修正しました。 –