Rupert Swarbrick <rswarbrick at gmail.com> writes:
> (defun print-to-stdout (x) (princ x *standard-output*))
>
> (with-output-to-string (*standard-output*)
> (print-to-stdout "Hello world")
> (values))
>
> More convoluted and more similar to the original:
>
> (with-output-to-string (strm)
> (let ((*standard-output* strm))
> (print-to-stdout "Hello world")
> (values)))
>
> has the same effect. I've just been staring at CLHS and can't find the
> relevant passage unfortunately. I think I want to say something like
> "LET binds a variable X to a new lexical binding, unless it already had
> a dynamic binding in which case it binds it dynamically", but I'm not
> sure where to look.
Of course, I found the passage I was looking for just after sending the
email. In the documentation for DECLARE:
When used in a proclamation, a special declaration specifier applies
to all bindings as well as to all references of the mentioned
variables. For example, after
(declaim (special x))
then in a function definition such as
(defun example (x) ...)
the parameter x is bound as a dynamic variable rather than as a
lexical variable.
Ta-Da!
Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20120111/5236b795/attachment.pgp>