guile-user
[Top][All Lists]
Advanced

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

Re: Using (SCM)0


From: Marius Vollmer
Subject: Re: Using (SCM)0
Date: Fri, 10 Oct 2003 18:46:50 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Ludovic Courtès <address@hidden> writes:

> Sure.  Actually I meant the following: Suppose I have a structure with
> an SCM field and I use calloc () to allocate it; can I write in my code
> something like:
>
>   if (object->field == (SCM)0)
>     /* Unitialized, assume there is no "real" Scheme object here */
>   else
>     /* Assume object->field is a "real" Scheme object */

Yes, you can do this (tho it might be easier to initialze the field
with SCM_BOOL_F once, say).

However (and I didn't think about this before) the type SCM is not
necessarily an integer or pointer.  It should be treated as opaque.
You need to use SCM_PACK:

  if (object->field == SCM_PACK (0))

but there is no real guarantee that SCM_PACK(0) is identical to
all-bits-zero.  Hmm.  It seems cleaner to avoid testing a SCM for
zero.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

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