unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* proposal: stricter type-checking for macros
@ 2004-03-25 12:23 Han-Wen Nienhuys
  2004-03-25 15:27 ` Paul Jarc
  0 siblings, 1 reply; 7+ messages in thread
From: Han-Wen Nienhuys @ 2004-03-25 12:23 UTC (permalink / raw)




Hi there,

after being bitten by a unnoticed type-error using SCM_CDRLOC, for the
umpteenth time, I submit a proposal that would make typechecking
macros stricter without the overhead of the union type
(SCM_DEBUG_TYPING_STRICTNESS == 2).

Here are a couple of tests. I'm not sure about the development
requirements for such code (one hack requires GCC, for instance), but
I think it should be switched on at all times. My preference is for

  /*
  works, but warning message sucks.
  */
  #define TYPECHECK(x)  (((x) - global_object) + global_object)

or

  /*
   works, GCC specific
  */
  #define TYPECHECK(x)  ({ SCM ___y = x; ___y; })

I am not sure of the performance penalties when compiling without -O2.
Maybe assembler gurus could comment?

It would also be nice if scm_unused_struct of the current code would
be changed in 

	struct scm_word {
	  long car;
	  long cdr; 
	};

or somesuch - it makes debugging a little easier.

****
struct scm_word {
  long car;
  long cdr; 
};

typedef struct scm_word * SCM;
SCM global_object;

inline SCM scm_identity (SCM x)
{
  return x;
}

/*
  ugh: evaluates X twice.
  */

// #define TYPECHECK(x)  (x == global_object) ? x : x;


/*
  works, but warning message sucks.
 */
#define TYPECHECK(x)  (((x) - global_object) + global_object)


/*
  works, performance hit (even with -O2) 
 */
// #define TYPECHECK(x)  (global_object = (x))

/*
  works, performance hit (without -O2)
 */
//#define TYPECHECK(x) scm_identity(x)

/*
  works, GCC specific
*/
//#define TYPECHECK(x)  ({ SCM ___y = x; ___y; })



SCM
f(SCM x, SCM y)
{
  SCM d = 0;
  d = TYPECHECK(x);
  d = TYPECHECK(&x);
  return d;
}



-- 

 Han-Wen Nienhuys   |   hanwen@xs4all.nl   |   http://www.xs4all.nl/~hanwen 



_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-04-24 23:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-25 12:23 proposal: stricter type-checking for macros Han-Wen Nienhuys
2004-03-25 15:27 ` Paul Jarc
2004-03-25 15:34   ` Han-Wen Nienhuys
2004-04-24 22:09     ` Marius Vollmer
2004-04-24 22:54       ` Han-Wen Nienhuys
2004-04-24 23:42         ` Marius Vollmer
2004-03-31 23:08   ` Paul Jarc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).