[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: library vs define-module issue
From: |
Zelphir Kaltstahl |
Subject: |
Re: library vs define-module issue |
Date: |
Sat, 1 Aug 2020 16:46:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.8.0 |
Thanks John! This solved the problem. I now have it like this:
~~~~START~~~~
(library (geometry (0 0 1))
(export point
make-point
get-point-label
get-point-coords
vector->point)
(import
(rnrs base)
(only (guile) lambda*)
;; structs
(srfi srfi-9)
(srfi srfi-9 gnu)
;; fold and list operations
(srfi srfi-1)))
... (other code) ...
~~~~~END~~~~~
and I can import that just fine.
Are all forms, which are usually available when using (define-module
...) exported in the import set (guile)?
If not, where would I look for them?
Using (help identifier) inside geiser helps. It shows me for example:
~~~~START~~~~
scheme@(guile-user)> (help define)
No documentation found for:
(rnrs base): define
~~~~~END~~~~~
Which tells me what I would need to import when using (library ...).
Best regards,
Zelphir
On 01.08.20 15:40, John Cowan wrote:
>
>
> On Sat, Aug 1, 2020 at 8:02 AM Zelphir Kaltstahl
> <zelphirkaltstahl@posteo.de <mailto:zelphirkaltstahl@posteo.de>> wrote:
>
>
> ;;; geometry.scm:25:0: warning: possibly unbound variable `define'
> ;;; geometry.scm:26:2: warning: possibly unbound variable `lambda*'
>
> 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 …)?
>
>
> Exactly. You have to import (rnrs base) or else (guile), because the
> global environment is empty at the start of an R[67]RS library
> definition. This is deliberate so that you can choose an entirely
> different base library if you wish. Similarly, Chicken provides both
> (scheme base) and (chicken base), and Chibi provides both (scheme
> base) and (chibi), although (chibi) is smaller than (scheme base)
> rather than larger, in keeping with Chibi's goals.
>
> As a matter of style, I recommend importing the standard base library
> and then bringing in anything Guile-specific with (import (only
> (guile) ...)). This advice also applies to Chibi, but not so much to
> Chicken unless you are specifically using the R7RS mode.
>
>
>
> John Cowan http://vrici.lojban.org/~cowan
> cowan@ccil.org <mailto:cowan@ccil.org>
> Is not a patron, my Lord [Chesterfield], one who looks with unconcern
> on a man struggling for life in the water, and when he has reached ground
> encumbers him with help? --Samuel Johnson
>
--
repositories: https://notabug.org/ZelphirKaltstahl