(defun list-bytes (number &optional byte-list
&key (min-list-length 0))
"Takes a number and gives a list of the 8-bit bytes it is comprised of
in largest first order. :min-list-length can be used to pad the beginning of
the list with zeros"
(if (zerop number)
(if (< (length byte-list) (print min-list-length))
(do ((ret-list byte-list (cons 0 ret-list)))
((>= (length ret-list) min-list-length)
ret-list))
(print byte-list))
(list-bytes (ash number -8)
(cons (logand #XFF number) byte-list))))
CLISP says:
> (list-bytes #XFFAA11 '() :min-list-length 10)
0 <-- min-list-length arg
(255 170 17)
(255 170 17)
> (list-bytes #XFFAA11 :min-list-length 10)
*** - EVAL/APPLY: keyword arguments for LIST-BYTES should occur pairwise
I have tried naming both arguments but that gives the same error as above. I
have also tried not giving min-l-l an initial value in the defun; same
problem.
Please help this dumb newbie out!
Cheers
Charlie.
Do (trace list-bytes) and try it again, observing the results.
You'll see the problem (it's in your code.)
Paul
You have to specify all optional positional arguments before the keyword
arguments can be processed. Otherwise, the keyword itself (which is an
actual argument) will /be/ the optional argument.
--
Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
(defun list-bytes (number &optional byte-list
&key (min-list-length 0))
> (list-bytes #XFFAA11 :min-list-length 10)
*** - EVAL/APPLY: keyword arguments for LIST-BYTES should occur pairwise
Thank-you
<kicks self>
Charlie.
"Erik Naggum" <er...@naggum.no> wrote in message
news:32473950...@naggum.no...
Yes, as Erik already pointed out, you always have to do this. If you
want to have calls that pass min-list-length but not byte-list you have
to change byte-list into a keyword with default value as well.
(defun list-bytes (number &key (byte-list '()) (min-list-length 0)))
Pascal
--
Pascal Costanza University of Bonn
mailto:cost...@web.de Institute of Computer Science III
http://www.pascalcostanza.de Römerstr. 164, D-53117 Bonn (Germany)