From: John Thingstad
Subject: 32 bit composition
Date: 
Message-ID: <op.s9j55q1jpqzri1@pandora.upc.no>
#-lispworks
(defstruct word (bytes 0 :type (unsiged-byte 32)))

(declaim (inline pack-bytes))
(defun pack-bytes (b0 b1 b2 b3)
   (declare (optimize (speed 3) (safety 0) (debug 0) (fixnum-safety 0))
            (type (unsigned-byte 8) b0 b1 b2 b3))
     (+ (ash b3 24) (ash b2 16) (ash b1 8) b0))

#+lispworks
(defun print-it ()
   (declare (optimize (speed 3) (safety 0) (debug 0) (fixnum-safety 0))
            (type (system:int32 my-word)))
   (let ((my-word (pack-bytes #xFF #xFF #xFF #xFF)))
     (format t "~&~X~%" my-word)))

#-lispworks
(defun print-it ()
   (declare (optimize (speed 3) (safety 0) (debug 0) (fixnum-safety 0)))
   (let ((my-word (make-word :bytes (pack-bytes #xFF #xFF #xFF #xFF))))
     (format t "~&~X~%" (word-bytes my-word))))

Tried my luck at some optimation issues the other day.
Any opinions?
The print-it is too lame.. the compiler can resove the value
at runtime.. But that is one of the values of making it
inline. It wouldn't resolve it without.
Don't really like the overhead of struct.. hence the LispWorks
spesific int32. If you have a efficient portable alternative
I would love to hear about it.
Am i right that fixnum-safety is ignored if it is not understood?

.................................................................
My motherboard went to lala land last month.
And with it a all Lisp interface to fastcgi.
I will implement it again only better (faster)
this time. (My old disk was ATA these are SATA)
.................................................................

Help me share..
(The devil is in the details)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/