[CM] Variables in R7RS libraries

Rudolf Adamkovič salutis at me.com
Fri Nov 25 11:36:15 PST 2022


Hi there!

R7RS libraries in s7 have issues with variables.  Our program consists
of about 30 libraries, and we store all program state in the variables
inside of these libraries.

Guile works as one would expect, but in s7, these variables have
unexpected values at runtime, depending who calls or imports whom, it
seems.

The R7RS standard says:

### Regardless of the number of times that a library is loaded, each
### program or library that imports bindings from a library must do so
### from a single loading of that library, regardless of the number of
### import declarations in which it appears.

We currently use the following workaround:

### ;; HACK state for s7 Scheme
### (cond-expand
###  (s7 (begin
###        (define var1 ...)
###        (define var2 ...)
###  (else))
###
### (define-library (app lib)
###
###   (export ...)
###   (import ...)
###
###   ;; HACK state (again), now for R7RS/Guile
###   (cond-expand
###      (guile (begin
###               (define var1 ...)
###               (define var2 ...))
###      (else))
###
###   (begin
###     
###     (define (...

We would like to do the following (which works in R7RS/Guile):

### (define-library (app lib)
###
###   (export ...)
###   (import ...)
###
###   (begin
###
### ;;; state
###     (define var1 ...)
###     (define var2 ...)
###
### ;;; procedures
###     (define (...

Any ideas?

Rudy
-- 
"Chop your own wood and it will warm you twice."
-- Henry Ford; Francis Kinloch, 1819; Henry David Thoreau, 1854

Rudolf Adamkovič <salutis at me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



More information about the Cmdist mailing list