Welcome to the CHICKEN Scheme pasting service

loader.scm pasted by siiky on Thu Nov 9 14:17:34 2023

(define (loader-printer s)
  (print "Hello, " s))

(define-syntax include-with-prelude
  (syntax-rules ()
    ((include-with-prelude path)
     (lambda (#!key printer)
       (include-relative path)))))

;(define loaded (include-with-prelude "loaded.scm")) ; doesn't work
(define loaded (lambda (#!key printer) (include-relative "loaded.scm")))

(loaded printer: loader-printer)

loaded.scm pasted by siiky on Thu Nov 9 14:17:58 2023

(loader-printer "loaded here")
(printer "loaded here")

no title pasted by siiky on Thu Nov 9 14:19:55 2023

$ csi -s loader.scm # not using include-with-prelude
Hello, loaded here
Hello, loaded here
$ csi -s loader.scm # using include-with-prelude
Hello, loaded here

Error: unbound variable: printer

	Call history:

	<syntax>	  [loaded] (##core#let ((printer51 (##sys#get-keyword (##core#quote #:printer) rest56))) (##core#let () (includ...
	<syntax>	  [loaded] (##core#begin (##core#let () (include-relative52 "loaded.scm")))
	<syntax>	  [loaded] (##core#let () (include-relative52 "loaded.scm"))
	<syntax>	  [loaded] (##core#begin (##core#include "loaded.scm" "loader.scm" ()))
	<syntax>	  [loaded] (##core#include "loaded.scm" "loader.scm" ())
	<syntax>	  [loaded] (##core#begin (loader-printer "loaded here") (printer "loaded here"))
	loaded.scm:1	  [loaded] (loader-printer "loaded here")
	loaded.scm:2	  [loaded] (printer "loaded here")
	<syntax>	  [loaded] (##sys#get-keyword (##core#quote #:printer) rest56)
	<syntax>	  [loaded] (##core#quote #:printer)
	loader.scm:13	  (loaded #:printer loader-printer)
	loader.scm:13	  (loaded #:printer loader-printer)
	<eval>	  [loaded] (##sys#get-keyword (##core#quote #:printer) rest56)
	loaded.scm:1	  [loaded] (loader-printer "loaded here")
	loader.scm:2	  [loader-printer] (print "Hello, " s)
	loaded.scm:2	  [loaded] (printer "loaded here")	<--

include-with-prelude added by siiky on Thu Nov 9 14:27:08 2023

(define-syntax include-with-prelude
  (er-macro-transformer
    (lambda (exp r c)
      (let ((path (cadr exp)))
        `(lambda (#!key printer)
                  (include-relative ,path))))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the equality predicate for strings in R5RS?
Visually impaired? Let me spell it for you (wav file) download WAV