unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Gubinelli Massimiliano <m.gubinelli@gmail.com>
To: guile-user@gnu.org
Subject: Problem with modules in Guile 2.0
Date: Tue, 6 Mar 2012 22:48:22 +0100	[thread overview]
Message-ID: <54183C89-DE93-417E-84EC-5C454E56EE35@gmail.com> (raw)

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






















             reply	other threads:[~2012-03-06 21:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06 21:48 Gubinelli Massimiliano [this message]
2012-03-07 20:11 ` Problem with modules in Guile 2.0 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54183C89-DE93-417E-84EC-5C454E56EE35@gmail.com \
    --to=m.gubinelli@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).