guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposal: stricter type-checking for macros


From: Han-Wen Nienhuys
Subject: Re: proposal: stricter type-checking for macros
Date: Thu, 25 Mar 2004 16:34:54 +0100

address@hidden writes:
> Han-Wen Nienhuys  <address@hidden> 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   |   address@hidden   |   http://www.xs4all.nl/~hanwen 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]