From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: Guile User <guile-user@gnu.org>
Subject: library vs define-module issue
Date: Sat, 1 Aug 2020 14:01:41 +0200 [thread overview]
Message-ID: <d204807f-0373-781f-f837-054108a25e92@posteo.de> (raw)
Hello Guile Users!
I've hit an issue, when trying to make use of (library ...) [1] instead
of (define-module ...) [2].
The file structure is as follows:
~~~~
.
├── example.scm
├── geometry-define-module.scm
└── geometry.scm
~~~~
When I define my module as follows, in geometry-define-module.scm, it works:
~~~~
(define-module (geometry-define-module)
#:export (point
make-point
get-point-label
get-point-coords))
(use-modules
(srfi srfi-9)
(srfi srfi-9 gnu))
(define-immutable-record-type <point>
;; define constructor
(point label coords)
;; define predicate
point?
;; define accessors and functional setters
(label get-point-label set-point-label)
(coords get-point-coords set-point-coords))
(define make-point
(lambda* (coords #:key (label #f))
(cond
[label
(point label coords)]
[else
(point 'unlabeled coords)])))
~~~~
I can import it in example.scm as follows (no errors):
~~~~
(use-modules (geometry-define-module))
~~~~
But when I define my module using library as follows:
~~~~
(library (geometry (0 0 1))
(export point
make-point
get-point-label
get-point-coords
)
(import
;; structs
(srfi srfi-9)
(srfi srfi-9 gnu)
;; hash table
#;(srfi srfi-69)))
(define-immutable-record-type <point>
;; define constructor
(point label coords)
;; define predicate
point?
;; define accessors and functional setters
(label get-point-label set-point-label)
(coords get-point-coords set-point-coords))
(define make-point
(lambda* (coords #:key (label #f))
(cond
[label
(point label coords)]
[else
(point 'unlabeled coords)])))
~~~~
I cannot import it, or rather there are errors:
~~~~
(import (geometry))
~~~~
Calling Guile as follows:
~~~~
guile -L . --fresh-auto-compile example.scm
~~~~
The error is:
~~~~
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/xiaolong/dev/Guile/algorithm-examples/basics/example.scm
;;; compiling ./geometry.scm
;;; geometry.scm:25:0: warning: possibly unbound variable `define'
;;; geometry.scm:26:2: warning: possibly unbound variable `lambda*'
;;; geometry.scm:26:11: warning: possibly unbound variable `coords'
;;; geometry.scm:26:25: warning: possibly unbound variable `label'
;;; geometry.scm:27:4: warning: possibly unbound variable `cond'
;;; geometry.scm:28:5: warning: possibly unbound variable `label'
;;; geometry.scm:29:6: warning: possibly unbound variable `label'
;;; geometry.scm:29:6: warning: possibly unbound variable `coords'
;;; geometry.scm:30:5: warning: possibly unbound variable `else'
;;; geometry.scm:31:13: warning: possibly unbound variable `quote'
;;; geometry.scm:31:13: warning: possibly unbound variable `unlabeled'
;;; geometry.scm:31:6: warning: possibly unbound variable `coords'
;;; compiled /home/xiaolong/.cache/guile/ccache/3.0-LE-8-4.3/home/xiaolong/dev/Guile/algorithm-examples/basics/geometry.scm.go
;;; WARNING: compilation of /home/xiaolong/dev/Guile/algorithm-examples/basics/example.scm failed:
;;; Unbound variable: define
~~~~
What am I doing wrong? Why is everything unbound, even core forms like
define or cond? Perhaps I need to import some base thing when using
(library …)?
Best regards,
Zelphir
[1]: https://www.gnu.org/software/guile/manual/html_node/R6RS-Libraries.html
[2]:
https://www.gnu.org/software/guile/manual/html_node/Creating-Guile-Modules.html
--
repositories: https://notabug.org/ZelphirKaltstahl
next reply other threads:[~2020-08-01 12:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-01 12:01 Zelphir Kaltstahl [this message]
2020-08-01 13:40 ` library vs define-module issue John Cowan
2020-08-01 14:46 ` Zelphir Kaltstahl
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=d204807f-0373-781f-f837-054108a25e92@posteo.de \
--to=zelphirkaltstahl@posteo.de \
--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).