unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Han-Wen Nienhuys  <hanwen@xs4all.nl>
Subject: proposal: stricter type-checking for macros
Date: Thu, 25 Mar 2004 13:23:01 +0100	[thread overview]
Message-ID: <16482.53029.540065.796985@localhost.localdomain> (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


             reply	other threads:[~2004-03-25 12:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-25 12:23 Han-Wen Nienhuys [this message]
2004-03-25 15:27 ` proposal: stricter type-checking for macros 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16482.53029.540065.796985@localhost.localdomain \
    --to=hanwen@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).