On Thu, Oct 05, 2023 at 08:39:48AM +0200, Damien Mattei wrote:
> hello,
> i have problem i do not understand when inserting a file in a module,
> things i never done before:
> 
> (define-module (matrix)
> 
>   #:use-module (oop goops)
> 
>   #:use-module ((guile)
>         #:select (*)
>         #:prefix orig:)
> 
>   #:export (<matrix>
>         matrix
>         matrix-v)
> 
>   )
> 
> (define scheme-plus-path "/Users/mattei/Dropbox/git/Scheme-PLUS-for-Guile")
> 
> (include (string-append scheme-plus-path "/Scheme+.scm"))
> 
> ...
> 
> i get this error:
> scheme@(guile-user)> (use-modules (matrix))
> ;;; note: source file /usr/local/share/guile/site/3.0/matrix.scm
> ;;;       newer than compiled
> /Users/mattei/.cache/guile/ccache/3.0-LE-8-4.6/usr/local/share/guile/site/3.0/matrix.scm.go
> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
> ;;;       or pass the --no-auto-compile argument to disable.
> ;;; compiling /usr/local/share/guile/site/3.0/matrix.scm
> ;;; WARNING: compilation of /usr/local/share/guile/site/3.0/matrix.scm failed:
> ;;; In procedure string-prefix?: Wrong type argument in position 2
> (expecting string): (string-append scheme-plus-path "/Scheme+.scm")
> While compiling expression:
> In procedure string-prefix?: Wrong type argument in position 2
> (expecting string): (string-append scheme-plus-path "/Scheme+.scm")
> 
> but it works if i replace the string-append by the string already appended :
> (include "/Users/mattei/Dropbox/git/Scheme-PLUS-for-Guile/Scheme+.scm")

I'd guess that the define makes the binding available at run
time and thus include comes "too early" (i.e. compile time):
the variable somehow already exists as far as include can see
but has no value...

I don't know whether it is TRT, but you might try wrapping your
define form in (eval-when (compile) ...) or similar.

But see the doc of eval-when, especially if you have any cats.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature

Reply via email to