Quote:

> What is meant by "boxing"? I'm quite new to lisp and not familiar

with

> this term.

From the Franz ACL5.0 documentation at:

http://www.franz.com/support/docs/5.0/doc/cl/compiling.htm

9.5 Explain boxing

A number is boxed when it is converted from its machine representation

to the Lisp representation. For floats, the machine representation is

one (for singles) or two (for doubles) words. Lisp adds an extra word,

which contain a pointer and a type code. For fixnums, boxing simply

involves a left shift of two bits. For bignums which are in the range

of machine integers, boxing again adds an additional word.

Boxing obviously involves a computational overhead, but more important

it involves a space overhead. If a calculation involves the calculation

of thousands of floats, for example, thousands of bytes of space will

be used. Often that space need not be used.

Quote:

> I had tried the function FLOAT with CMUCL, but that consed a lot

> (perhaps misdeclarations).

> Is (coerce a 'double-float) and (float a 0.0d0) the same, i.e. are

they

> optimized into

> the same code?

They are not the same with Franz's ACL. Using float is more efficient.

But this doesn't necessarily apply to CMUCL. You can use disassemble to

compare the two approaches. For example with ACL:

(defun c1 (a) (float a 0.0d0))

(defun c2 (a) (coerce a 'double-float))

(disassemble 'c1)

;; disassembly of #<Function C1>

;; formals: A

;; code start: #x127b65fc:

0: 37de0080 ldo 64(r30),r30

4: 6bc23f59 stw r2,-84(0,r30)

8: 6bd13fe1 stw r17,-16(0,r30)

12: b08037ff addit,<> -1,r4,r0 "number of args"

16: b1403000 addit,<> 0,r10,r0 "c_interrupt"

20: 4a483b1d ldw -626(0,r18),r8 DOUBLE-FLOAT

24: e520e000 ble 0(sr7,r9)

28: 34040002 [ldo] ldi #x1,r4

32: 4bc23f59 ldw -84(0,r30),r2

36: 37de3f81 ldo -64(r30),r30

40: e13fffed be -12(sr7,r9)

44: 4bd13fe1 ldw -16(0,r30),r17

(disassemble 'c2)

;; disassembly of #<Function C2>

;; formals: A

;; constant vector:

0: COERCE

;; code start: #x127ccf44:

0: 37de0080 ldo 64(r30),r30

4: 6bc23f59 stw r2,-84(0,r30)

8: 6bd13fe1 stw r17,-16(0,r30)

12: b08037ff addit,<> -1,r4,r0 "number of args"

16: b1403000 addit,<> 0,r10,r0 "c_interrupt"

20: 4a593b1d ldw -626(0,r18),r25 DOUBLE-FLOAT

24: 4a280056 ldw 43(0,r17),r8 COERCE

28: e520e000 ble 0(sr7,r9)

32: 34040004 [ldo] ldi #x2,r4

36: 4bc23f59 ldw -84(0,r30),r2

40: 37de3f81 ldo -64(r30),r30

44: e13fffed be -12(sr7,r9)

48: 4bd13fe1 ldw -16(0,r30),r17

--

John Watton

Alcoa Inc.

Sent via Deja.com http://www.deja.com/

Before you buy.