Re: sanity check (coding style)



In article <1133313533.141217.158020@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
josephoswaldgg@xxxxxxxxxxx <josephoswald@xxxxxxxxx> wrote:
> 2) I originally expected with-output-to-string to capture princ's
> output, and tried just
>
> (with-output-to-string (s) (map nil #'princ v) s)
>
> but of course princ still goes to *standard-ouput* without the extra
> argument, which requires an anonymous function.

(asdf:operate 'asdf:load-op :arnesi)
(with-output-to-string (s) (map nil (arnesi:rcurry #'princ s) v))

> I had expected to find
> a built-in macro to divert everything destined for a stream (defaulting
> to *standard-output*) to a string, then return that string.

(with-output-to-string (*standard-output*) (map nil #'princ v))

Remember, any binding construct with a special variable will make a
dynamic binding, not just LET and friends.

You also needn't return the string-stream out of the expression as you
did above. WITH-OUTPUT-TO-STRING always returns the generated string.
If it returned the stream you wouldn't get what you wanted.

-bcd
--
*** Brian Downing <bdowning at lavos dot net>
.