This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: docstrings in Guile!
>>>>> "Greg" == Greg J Badros <gjb@cs.washington.edu> writes:
Greg> Daniel Skarda <0rfelyus@atrey.karlin.mff.cuni.cz> writes:
Greg> But that's the point: you don't *have* to rewrite all existing
Greg> code; it's just a performance optimization to rewrite the
Greg> existing code, along with a simplification of that code.
Not even much of a performance optimization:
I took this code and compiled it with gcc:
#include <guile/gh.h>
#define TEST(x) (SCM_NIMP((x)) && SCM_VECTORP((x)))
SCM
foo (SCM x)
{
if(TEST(x))
return x;
return SCM_BOOL_F;
}
SCM
bar (SCM x)
{
if(SCM_NIMP(x) && TEST(x))
return x;
return SCM_BOOL_F;
}
And got this assembly:
.file "test.c"
.version "01.01"
gcc2_compiled.:
.text
.align 4
.globl foo
.type foo,@function
foo:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%edx
testb $6,%dl
jne .L18
movl (%edx),%eax
andl $125,%eax
cmpl $13,%eax
jne .L18
movl %edx,%eax
jmp .L21
.p2align 4,,7
.L18:
movl $8564,%eax
.L21:
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size foo,.Lfe1-foo
.align 4
.globl bar
.type bar,@function
bar:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%edx
testb $6,%dl
jne .L20
movl (%edx),%eax
andl $125,%eax
cmpl $13,%eax
jne .L20
movl %edx,%eax
jmp .L22
.p2align 4,,7
.L20:
movl $8564,%eax
.L22:
movl %ebp,%esp
popl %ebp
ret
.Lfe2:
.size bar,.Lfe2-bar
.ident "GCC: (GNU) 2.95 19990728 (release)"
The optimizer optimizes the extra test out anyway :)