- (let ((lily-string (call-with-output-string
- (lambda (out)
- (do ((c (read-char port) (read-char port)))
- ((and (char=? c #\#)
- (char=? (peek-char port) #\})) ;; we stop when #} is encountered
- (read-char port))
- ;; a #scheme or $scheme expression
- (if (or (char=? c #\#) (char=? c #\$))
- (format out "~a~s" c (read port))
- ;; other characters
- (display c out)))))))
+ (let* ((closures '())
+ (lily-string (call-with-output-string
+ (lambda (out)
+ (do ((c (read-char port) (read-char port)))
+ ((and (char=? c #\#)
+ (char=? (peek-char port) #\})) ;; we stop when #} is encountered
+ (read-char port))
+ ;; a #scheme or $scheme expression
+ (if (or (char=? c #\#) (char=? c #\$))
+ (begin
+ (set! closures (cons (read port) closures))
+ (format out "~a~s" c (car closures)))
+ ;; other characters
+ (display c out)))))))