This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: guile bugs


Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:

> > 1) SCM_BOOL_F should be 0 so it is false in C
> 
> I don't like this argument.  It's not true that this change would
> eliminate bugs.  Using SCM values directly in C is a violation of the
> abstraction barrier and clearly a bug. The suggested change would, in
> fact, multiply them.  It would make code with this type of bug work,
> so that they are harder to find.

I fully agree with the above sentiment, however, it's not the main
problem. The main problem is that C compiler won't report errors like

if (scm_procedure_p(foo))
    ...

It won't even complain about them.

I think SCM should be

typedef union {
    void *ptr;
    long value;
    float float_value; /* for CDR parts of float pairs */
} SCM;

Now /this/ would trap most bugs. But I'm not sure about the efficiency
issues (gcc may overoptimize functions returning SCM structs, and use
pointers rather than registers... This should be investigated). It
would also trap problems such as

*(Foo_smob*)SCM_CDR(foo) = whatever

(rather than SCM_SET_CDR(foo, whatever))

- while these expressions are equivalent with the current
implementation, it could bomb with write barrier in place.

-- 
How to eff the ineffable?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]