unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: John Cowan <cowan@ccil.org>
Cc: Guile User <guile-user@gnu.org>
Subject: Re: library vs define-module issue
Date: Sat, 1 Aug 2020 16:46:42 +0200	[thread overview]
Message-ID: <6037dcbe-cd52-3964-9aac-016ab424dc3d@posteo.de> (raw)
In-Reply-To: <CAD2gp_Q1PTFeHU0OfXA3LQ0qpsB5Y-cCg_+NtxgYsTvc+BVH7Q@mail.gmail.com>

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



      reply	other threads:[~2020-08-01 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-01 12:01 library vs define-module issue Zelphir Kaltstahl
2020-08-01 13:40 ` John Cowan
2020-08-01 14:46   ` Zelphir Kaltstahl [this message]

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=6037dcbe-cd52-3964-9aac-016ab424dc3d@posteo.de \
    --to=zelphirkaltstahl@posteo.de \
    --cc=cowan@ccil.org \
    --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).