unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Problem with modules in Guile 2.0
@ 2012-03-06 21:48 Gubinelli Massimiliano
  2012-03-07 20:11 ` Mark H Weaver
  2012-03-07 20:32 ` Andy Wingo
  0 siblings, 2 replies; 10+ messages in thread
From: Gubinelli Massimiliano @ 2012-03-06 21:48 UTC (permalink / raw)
  To: guile-user

Hi all,
  I stumbled on a strange behaviour of Guile 2.0, I have the following three files: main.scm, test-module.scm and sub/mymodule.scm which respectively contain

---- main.scm 

(load "test-modules.scm")

(inherit-modules (sub mymodule))

(display (pippo 10 20)) (display "\n")


---- sub/mymodule.scm 

(texmacs-module (sub mymodule))


(display "Loading my module\n")

(define-public (pippo a b)
 (+ a b))
 
 
---- test-modules.scm 

(define texmacs-user (current-module))
(define temp-module (current-module))

(define-macro (with-module module . body)
  `(begin
     (set! temp-module (current-module))
     (set-current-module ,module)
     ,@body
     (set-current-module temp-module)))


(define-macro (import-from . modules)
	`(process-use-modules
	  (list ,@(map (lambda (m)
			 `(list ,@(compile-interface-spec m)))
		       modules))))
      

(define-macro (inherit-modules . which-list)
  (define (module-exports which)
    (let* ((m (resolve-module which))
	   (m-public (module-ref m '%module-public-interface)))
      (module-map (lambda (sym var) sym) m-public)))
  (let ((l (apply append (map module-exports which-list))))
    `(begin
       (use-modules ,@which-list)
       (re-export ,@l))))

(define-macro (texmacs-module name . options)
  (define (transform action)
    (cond ((not (pair? action)) (noop))
	  ((equal? (car action) :use) (cons 'use-modules (cdr action)))
	  ((equal? (car action) :inherit) (cons 'inherit-modules (cdr action)))
	  ((equal? (car action) :export)
	   (display "Warning] The option :export is no longer supported\n")
	   (display "       ] Please use tm-define instead\n"))
	  (else '(noop))))
  (let ((l (map-in-order transform options)))
	(set! l (cons `(module-use! (current-module) ,texmacs-user) l))
    (display "loading ") (display name) (display "\n")
    `(begin
       (define-module ,name)
       ,@l)))

-----------

the directory structure is the following

./main.scm
./test-modules.scm
./sub/mymodule.scm

these are pieces from a larger software (GNU TeXmacs) which used to work with any version of Guile up to 1.8 and fail to work with Guile 2.0. In an interactive session, after setting the GUILE_LOAD_PATH to the working directory I get


---------------------------
Jurgen:test-modules mgubi$ GUILE_LOAD_PATH=$PWD guile
GNU Guile 2.0.5
Copyright (C) 1995-2012 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (load "main.scm")
;;; note: source file /Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm
;;;       newer than compiled /Users/mgubi/.cache/guile/ccache/2.0-LE-8-2.0/Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm
;;; main.scm:3:0: warning: possibly unbound variable `inherit-modules'
;;; main.scm:3:17: warning: possibly unbound variable `sub'
;;; main.scm:3:17: warning: possibly unbound variable `mymodule'
;;; main.scm:5:9: warning: possibly unbound variable `pippo'
;;; compiled /Users/mgubi/.cache/guile/ccache/2.0-LE-8-2.0/Users/mgubi/t/build-64-guile-2.0/test-modules/main.scm.go
main.scm:3:17: In procedure #<procedure 109cfed80 ()>:
main.scm:3:17: In procedure module-lookup: Unbound variable: sub

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 
---------------------------

The same code work fine with 1.6:

Jurgen:test-modules mgubi$ GUILE_LOAD_PATH=$PWD ../../build-64-guile-1.6.8/usr/bin/guile
guile> (version)
"1.6.8"
guile> (load "main.scm")
loading (sub mymodule)
Loading my module
30
guile> 

---------------------------

Somebody has a clue on how to fix this and what is the origin of the problem?

Thanks,

Massimiliano Gubinelli






















^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-03-13  1:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 21:48 Problem with modules in Guile 2.0 Gubinelli Massimiliano
2012-03-07 20:11 ` Mark H Weaver
2012-03-07 20:32 ` Andy Wingo
2012-03-07 22:52   ` Gubinelli Massimiliano
2012-03-08  2:01     ` Mark H Weaver
2012-03-09  0:03       ` Gubinelli Massimiliano
2012-03-09 16:29         ` Mark H Weaver
2012-03-10  0:33           ` Gubinelli Massimiliano
2012-03-11 20:38             ` Mark H Weaver
2012-03-13  1:10               ` Gubinelli Massimiliano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).