On 15 Dec 2006 02:03:36 +0200, Juho Snellman <jsnell@...> wrote:
> I'm not sure what an unboxed struct would look like. A structure will
> always be boxed in memory somehow. SBCL doesn't currently do stack
> allocation for structures, even with :type vector and with the
> suitable dynamic-extent declarations, so it'll have to be allocated on
> the heap.
Ok, thanks for clearing that up.
> Something I wrote a while ago: <http://jsnell.iki.fi/tmp/mv4.lisp>
> Basically it's sugar for easily converting between structs and
> multiple values, and for easily defining operators that can work with
> either representation. (Don't pay too much attention to the crappy
> raytracer in that file).
Thank you, that is very interesting. I'm toying with something similar
here and seeing much less consing than what I did with arrays. There's
still _some_ consing, though. Do multiple-values-bind and values cons
in the general case or have I done something stupid, as in:
(defun f (a b c)
(type single-float a b c))
(values (+ a b) (- b a) (* c a)))
(defun test ()
(dotimes (k 100000000)
(let ((i (coerce k 'single-float)))
(multiple-value-bind (x y z) (f i (+ i 10) (* i 20))
3.328 seconds of real time
3.328208 seconds of user run time
0.0 seconds of system run time
0 page faults and
16,320 bytes consed.
Why would this cons? Is it because my loop counter is becoming a large
enough fixnum that it has to be promoted to some arbitrary precision
> The data is properly aligned in memory, but the pointer to the array
> will have a tag, which needs to be adjusted for.
Cool, just what I was hoping for :)
My other car is a cons.