1. live-define
    1. Requirements
    2. Documentation
    3. Examples
    4. Version History
      1. Version 1.1
      2. Version 1.0
    5. Source repository
    6. Authors
    7. License

Hack to simplify some cases of interactive development.



[syntax] (define name (lambda arguments body ...))
[syntax] (define (name arguments) body ...)

A macro that replaces the standard Scheme define with one that, when it detects that a procedure is bound to name, mutates that procedure in place instead of binding the name to a new procedure.

This is useful in situations where you pass the procedure name as an argument to another and want to change it’s behavior while the program is running. For example by using your text editor’s facility to send code to a running instance of csi.

Please note that this is only intented to be used within the interpreter and will probably break in various ways if used in compiled code


This is a pretty contrived example, but it shows the modified behavior quite well.

Run it with csi -s example.scm

(import srfi-18)

;; try commenting this next line to see the standard behavior
(import live-define)

(define (thread-proc thunk)
  (lambda ()
    (let lp ()
      (thread-sleep! 1)

(define (the-thunk)
  (print "hi!"))

(thread-start! (thread-proc the-thunk))
;; -> prints "hi!" every second

(thread-sleep! 5)

(define (the-thunk)
  (print "coucou !"))
;; -> thread now prints "coucou !" every second

(thread-sleep! 5)

Version History

Version 1.1

30 November 2018

Version 1.0

30 November 2018

Source repository

Source available in a git repository

Bug reports and patches welcome! Bugs can be reported to


Adrien (Kooda) Ramos


Public Domain