Re: sanity check (coding style)



Peter Seibel <peter@xxxxxxxxxxxxxxx> writes:

> tar@xxxxxxxxxxxxx (Thomas A. Russ) writes:
>
>> This is nice, since it uses the string stream to collect the values. If
>> efficiency is really critical, one could avoid the FORMAT call (which
>> often tends to be slow) and subsitute a 256 element lookup table:
>>
>> (defconstant *hex-codes* #("00" "01" ... "FF"))
>
> Surely we don't have to write that by hand; that's not The Lisp Way!
>
> (defconstant *hex-codes* #.(coerce (loop for i from #x00 to #xff collect (format nil "~2,'0x" i)) 'vector))

Well, you can write that, but it's not the SBCL way, as it will rudely
remind you if you reexecute that definition ;-)

Christophe

[ (let ((hex-codes #.(coerce ...)))
(defun ...)) ]
.



Relevant Pages

  • Re: sanity check (coding style)
    ... Christophe Rhodes writes: ... >> tar@xxxxxxxxxxxxx (Thomas A. Russ) writes: ... since it uses the string stream to collect the values. ...
    (comp.lang.lisp)
  • Re: sanity check (coding style)
    ... tar@xxxxxxxxxxxxx (Thomas A. Russ) writes: ... since it uses the string stream to collect the values. ... > efficiency is really critical, one could avoid the FORMAT call (which ...
    (comp.lang.lisp)
  • Re: Default VK_Enter action in JText* component
    ... Thomas A. Russ, USC/Information Sciences Institute ... //Basic contents of the frame. ... JTextPane inputArea; ...
    (comp.lang.java.gui)
  • Re: Whats so great about lisp?
    ... Addition and subtraction are allowed if the units rationals are =, ... There is a paper about this that was published in Lisp Pointers: ... Thomas A. Russ, USC/Information Sciences Institute ...
    (comp.lang.lisp)
  • Re: style question: FORMAT vs VECTOR-PUSH-EXTEND
    ... the last character is not a substitution, you lose the last bit of ... >> Then just use a hashtable of character substitutions. ... Thomas A. Russ, USC/Information Sciences Institute ...
    (comp.lang.lisp)