Chibi Scheme modules

worker.sld

(define-library (worker)
    (export make-worker)
    (import (scheme base))
    (include "worker.scm")
) ;; end library worker

worker.scm

(define (make-worker n)
    (lambda ()  (set! n (+ n 1))  n) )

main.scm

#!/usr/bin/env chibi-scheme

(import (scheme base)
    (scheme write)
    (scheme process-context)
    (worker)
)

(define (print . args)
    (for-each display args)
    (newline) )

(define (main argv)
    (print argv)
    (let ( (w (make-worker 0)) )
        (print "worker: " (w))
        (print "worker: " (w))
        (print "worker: " (w)) ) )

(main (cdr (command-line))) ;; or remove this line, add -r to shebang line

run as script

% ./main.scm

One thought on “Chibi Scheme modules”

  1. My Scheme Stuff: Category: Scheme: My blog posts on Scheme. scheme-test-unit: My unit test runner for SRFI-64. Basic Games in Scheme: Classic BASIC games &…

Comments are closed.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)

Mentions

  • My Scheme Stuff: Category: Scheme: My blog posts on Scheme. scheme-test-unit: My unit test runner for SRFI-64. Basic Games in Scheme: Classic BASIC games &…

Mentions

  • Mark writes