So when you quote data it's like single quotes in some popular Algol dialects like perl. eg print '$_';
actually prints $_ and not the value the variable $_ represents. If you would have used double quotes the variables in the string is expanded to it's value.
In Scheme we have (quote x)
which is 'x
. Nothing in it will ever going to become evaluated since it's quoted with '
. If it were `x
, which is the same as (quasiquote x)
then Scheme looks for ,expression
(same as (unquote expression)
) and ,@expression
(same as (unquote-splicing expression)
). These quote forms are NOT procedures but macros. It transforms your static code to different static code.
So (begin (define test 10) `((1 2) (3 ,(+ test 4)))) ; ==> ((1 2) (3 14))
What Scheme really does is transform it into (list '(1 2) (list 3 (+ test 4)))
, while if it was `((3 ,(+ test 4)) (1 2))
it turns into (cons (list 3 (+ test 4)) '((1 2)))
since the tail can be a constant but the head cannot if it needs to have a evaluated tail.
I get the impression from you question that you think you can store the text and expand them later like (let ((x '((1 2) (3 ,(+ test 4))))) `x)
but that will not work since quasiquote
is a macro and thus it will evaluate to x. and (let ((x '((1 2) (3 ,(+ test 4))))) `,x)
would evaluate to ((1 2) (3 ,(+ test 4)))
.