
Why quasiquote without macros?
Quote:
> (define immutable-list '(red green)) ; see sec. 3.5 of standard
> (define initialized-mutable-list `(red green))
but as Lars Thomas Hansen was the first to point out in email, I was wrong
to assume that `(red green) must return a mutable list. It just happens
that the Scheme implementation *I* use allows me to mutate it...
The R4RS says in section 3.5 that
# The constants and the strings returned by symbol->string are ... the
# immutable objects, while all objects created by the other procedures
# listed in this report are mutable.
and in section 4.1.2, essentially, that '(red green) is a constant that
therefore immutable. Now section 4.2.6 says:
# If no commas appear within the <template>, the result of evaluating
# `<template> is equivalent to the result of evaluating '<template>.
If quasiquote was a procedure, it would have to return a mutable list, but
it's syntax, and the above wording makes its result immutable. (That is,
the implementation is allowed to enforce its immutability).
However, at least, my second example of quasiquote's utility stands.
--
SoftQuad Inc., Toronto -- Tom Van Vleck
This article is in the public domain.