Re: sanity check (coding style)
- From: "josephoswaldgg@xxxxxxxxxxx" <josephoswald@xxxxxxxxx>
- Date: 29 Nov 2005 18:10:09 -0800
Brian Downing wrote:
> In article <1133313533.141217.158020@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> josephoswaldgg@xxxxxxxxxxx <josephoswald@xxxxxxxxx> wrote:
>
> > 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.
OW! You made my head hurt. :-)
> 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.
Not sure what mistake I got that made me think otherwise. I think
reading the CLHS entry bit about the optional argument "string"
confused me.
Still, to get dependable 2-digit results, I'm not sure I like anything
better than
(format t "~2,'0X" e)
> -bcd
> --
> *** Brian Downing <bdowning at lavos dot net>
(defun digest2string (v)
(with-output-to-string (s)
(map nil #'(lambda (e) (format s "~2,'0X" e)) v)))
.
- References:
- sanity check (coding style)
- From: Sylvain
- Re: sanity check (coding style)
- From: Christophe Rhodes
- Re: sanity check (coding style)
- From: Sylvain
- Re: sanity check (coding style)
- From: josephoswaldgg@xxxxxxxxxxx
- Re: sanity check (coding style)
- From: Brian Downing
- sanity check (coding style)
- Prev by Date: Re: a clisp problem
- Next by Date: Re: recursion performance
- Previous by thread: Re: sanity check (coding style)
- Next by thread: Re: sanity check (coding style)
- Index(es):
Relevant Pages
|
|