From: mdj on
On Jan 4, 3:22 pm, Kenneth Tilton <kentil...(a)gmail.com> wrote:

> > False.  Structures are not always faster than plist.  Notaby,
> > implementations may typecheck the structure object, which slows
> > structure accessors so much that plist up to 5 or even more slots is
> > faster.
>
> Rubbish! What crappy implementation are you imagining for these
> incredibly slow defstructs (by which I mean which Lisp and how do they
> implement defstructs by default? Lemme see some timings!

Unless the structures were implemented with conses this seems almost
impossible, since a slot access can be compiled out to nothing more
than indexed addressing! And the type check is what, a single
compare ?

From: Kenneth Tilton on
mdj wrote:
> On Jan 4, 3:22 pm, Kenneth Tilton <kentil...(a)gmail.com> wrote:
>
>>> False. Structures are not always faster than plist. Notaby,
>>> implementations may typecheck the structure object, which slows
>>> structure accessors so much that plist up to 5 or even more slots is
>>> faster.
>> Rubbish! What crappy implementation are you imagining for these
>> incredibly slow defstructs (by which I mean which Lisp and how do they
>> implement defstructs by default? Lemme see some timings!
>
> Unless the structures were implemented with conses this seems almost
> impossible, since a slot access can be compiled out to nothing more
> than indexed addressing!

Yep.

> And the type check is what, a single
> compare ?
>

Type-checking is for Java/C++ wusses! I always get a kick out of struct
accessors working on the wrong struct when I screw up. Same thing with
coding the wrong copier: copies fine!

kt

--

http://thelaughingstockatpngs.com/
http://www.facebook.com/pages/The-Laughingstock/115923141782?ref=nf
From: mdj on
On Jan 4, 4:33 pm, Kenneth Tilton <kentil...(a)gmail.com> wrote:

> Type-checking is for Java/C++ wusses! I always get a kick out of struct
> accessors working on the wrong struct when I screw up. Same thing with
> coding the wrong copier: copies fine!

Well, 'correct' programs don't need it :-) I like the "lisp way" of
providing runtime checking until I decide I need the speed more than
the belt ...
From: Pillsy on
On Jan 3, 12:34 am, Kenneth Tilton <kentil...(a)gmail.com> wrote:
[...]
> I suggest you write the code you are writing now and not the code you
> might write someday.
[...]
I nominate this for the Kenny fortune file.

Cheers,
Pillsy
From: Pascal J. Bourguignon on
Kenneth Tilton <kentilton(a)gmail.com> writes:

> Pascal J. Bourguignon wrote:
>
>>> Using a plist is not the lay to go. Use defstruct. Simpler than a
>>> plist, really, and massively more efficient.
>>
>> False. Structures are not always faster than plist. Notaby,
>> implementations may typecheck the structure object, which slows
>> structure accessors so much that plist up to 5 or even more slots is
>> faster.
>
> Rubbish! What crappy implementation are you imagining for these
> incredibly slow defstructs (by which I mean which Lisp and how do they
> implement defstructs by default? Lemme see some timings!
>
> kt

Existance proof:

C/USER[11]> (defstruct ss a b c d e)
SS
C/USER[12]> (let ((s (make-ss :a 42))) (time (loop :repeat 100000 :do (ss-a s))))
Real time: 0.494208 sec.
Run time: 0.464029 sec.
Space: 804400 Bytes
NIL
C/USER[13]> (defstruct (sl (:type list)) a b c d e)
SL
C/USER[14]> (let ((s (make-sl :a 42))) (time (loop :repeat 100000 :do (sl-a s))))
Real time: 0.489189 sec.
Run time: 0.424026 sec.
Space: 804400 Bytes
GC: 1, GC time: 0.012001 sec.
NIL
C/USER[15]> (values (lisp-implementation-type) (lisp-implementation-version))
"CLISP" ;
"2.41 (2006-10-13) (built on thalassa.lan.informatimago.com [192.168.1.198])"

C/USER[17]> (disassemble 'ss-a)

Disassembly of function SS-A
(CONST 0) = SS
(CONST 1) = 1
1 required argument
0 optional arguments
No rest parameter
No keyword parameters
5 byte-code instructions:
0 (CONST&PUSH 0) ; SS
1 (LOAD&PUSH 2)
2 (CONST&PUSH 1) ; 1
3 (CALLS2 47) ; SYSTEM::%STRUCTURE-REF
5 (SKIP&RET 2)
NIL
C/USER[18]> (disassemble 'sl-a)

Disassembly of function SL-A
1 required argument
0 optional arguments
No rest parameter
No keyword parameters
3 byte-code instructions:
0 (LOAD 1)
1 (CAR)
2 (SKIP&RET 2)
NIL
C/USER[19]>

--
__Pascal Bourguignon__ http://www.informatimago.com/