unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Han-Wen Nienhuys  <hanwen@xs4all.nl>
Cc: guile-devel@gnu.org
Subject: Re: proposal: stricter type-checking for macros
Date: Thu, 25 Mar 2004 16:34:54 +0100	[thread overview]
Message-ID: <16482.64542.175708.694774@localhost.localdomain> (raw)
In-Reply-To: <m31xnhvtdj.fsf@multivac.cwru.edu>

prj@po.cwru.edu writes:
> Han-Wen Nienhuys  <hanwen@xs4all.nl> wrote:
> > // #define TYPECHECK(x)  (global_object = (x))
> 
> #define TYPECHECK(x) (0? (void)(*(SCM*)0=(x)): (void)0)
> 
> Casting to void ensures that the resulting "value" won't accidentally
> be used for anything.  "0?" ensures that the null pointer won't
> actually be dereferenced.  I'd expect dead-code elimination to compile
> this into nothing, but I haven't checked which optimization level this
> happens for.


Very clever!

I vote for

  #define TYPECHECKED(x) (0? (*(SCM*)0=(x)): x)

which returns x, and obviates the void casting.

-- 

 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 15:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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.64542.175708.694774@localhost.localdomain \
    --to=hanwen@xs4all.nl \
    --cc=guile-devel@gnu.org \
    /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).