In scheme, it is possible to use set! to create two (or more) functions which share a private scope between them:
(define f1 #f) ; or any other "undefined" value
(define f2 #f)
(let ((private some-value) (another-private some-other-value))
(set! f1 (lambda ... <use of private variables> ...))
(set! f2 (lambda ... <use of private variables> ...)))
or by using a third variable:
(define functions
(let ((private some-value) (another-private some-other-value))
(list (lambda ... <use of private variables> ...)
(lambda ... <use of private variables> ...))))
(define f1 (car functions))
(define f2 (cadr functions))
However, both of these seem inelegant, due to the use of set! in the first and the left-over variable functions in the second. Is there a way to do this without either?
1 Answer