[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: library vs define-module issue
From: |
John Cowan |
Subject: |
Re: library vs define-module issue |
Date: |
Sat, 1 Aug 2020 09:40:12 -0400 |
On Sat, Aug 1, 2020 at 8:02 AM Zelphir Kaltstahl <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
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