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]

typedef struct SCM



Hi list,

after squashing the umpteenth type conversion bug in Lily, I'm
submitting the following proposal.

How about changing the type of SCM from

    typedef long SCM;

to

	typedef struct {
		long object;
		} SCM;

Since this doesn't really change anything for compiler (afaict), this
should not make a difference for the performance of GUILE.  Since SCM
values are always accessed using functions and macros this should also
not make a difference for the source code.

It would however squash the following type of bug (which is all too
easy to make, and goes unnoticed by the compiler)

     int foo = 0;

     /* this should use gh_int2scm (foo) */
     set_property (gh_symbol2scm ("bar"), foo)

     /* kaboom: you get SIGSEGV when accessing foo, since GUILE
     thinks it is a NIMP */


You get similar errors if you accidentally type gh_scm2int in stead of
gh_int2scm.  It is especially nasty to track down this sort of error
if it this signaled from inside scm_gc_mark.

I recall that a similar discussion has taken place on the list a
few months ago, but I can't recall the details.

Are there  reasons against doing this change? If so, what are they?

-- 

Han-Wen Nienhuys, hanwen@cs.uu.nl ** GNU LilyPond - The Music Typesetter 
      http://www.cs.uu.nl/people/hanwen/lilypond/index.html 


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