postponing unquote
I need to generate S-expressions like:
(let ((val "datum")) val)
The actual expressions are more complex, the value "datum" is dynamic, therefore the special Scheme feature "quasiquote" should be used:
(quasiquote (let ((val ,value)) val))
When a Scheme imterpreter/compiler finds a "quasiquote" construction, it replaces comma-starting identifiers with their values.
To add more complexity, I have to generate the skeleton of an S-expression at one time, and provide actual values later. Surprisingly for me, I needed only one attempt to write a working test code:
(define (pre-generate)
(lambda (value)
(quasiquote
(let ((val ,value))
val))))
(define x (pre-generate))
(write x)
(display "\n")
(define y (x "datum"))
(write y)
(display "\n")
Executing code in Guile:
#
(let ((val "datum")) val)
In Bigloo:
#
(let ((val "datum")) val)
Categories: