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

Re: no constants please

This page is part of the web mail archives of SRFI 50 from before July 7th, 2015. The new archives for SRFI 50 contain all messages, not just those from before July 7th, 2015.



   From: Ken Dickey <Ken.Dickey@xxxxxxxxxxxxxx>
   Date: Wed, 31 Dec 2003 09:22:57 +0100

   On Wednesday 31 December 2003 03:51 pm, Richard Kelsey wrote:
   > Are there any implementations of Scheme in use where SCHEME_FALSE,
   > SCHEME_TRUE, SCHEME_NULL, or SCHEME_UNSPECIFIC should be freshly
   > allocated?  Or where EQ? and == are not equivalent?  (These are not
   > rhetorical questions; I really would like to know -- is this an
   > existing or only potential problem for portability?)

   This is not exhaustive, but a quick look at a few Schemes on my disk reveals 
   that quite a few Schemes do use "constant objects":

Constant objects aren't the issue.  I am curious as to whether their
are implementations where:
  - It is not okay to reuse the same value for multiple
    instances of one of these constants? 
  - EQ? is not equivalent to comparing two fixed-sized chunks
    of bits?  (Because that is what C's == does.)
These two are related; if you use C's (or Java's) == for EQ? then
you can't have multiple instances of #t, #f, or ().

	   Kawa  [boolean? is a test for instance of Boolean class]
Kawa uses Java's == for EQ?, so it isn't what I am looking for
(there can be only one instance of #T, #F, and ()).

	   Stklos
	   SXM
	   TinyScheme
	   Gauche

Stklos, SXM, TinyScheme, and Gauche all implement EQ? as C's ==.
So they are standard as well.

(By the way, the current version of Stklos doesn't use
 pointers for these constants; I didn't check any earlier
 versions.

 From stklos.h (version 0.56):

  #define AS_SCM(x)		((SCM) ((unsigned long) (x)))
  ...
  #define MAKE_SCONST(n)   (AS_SCM(n << 2 | 3))
  ...
  #define STk_nil		((SCM) MAKE_SCONST(0))
  #define STk_false	((SCM) MAKE_SCONST(1))
  #define STk_true	((SCM) MAKE_SCONST(2))
  #define STk_eof		((SCM) MAKE_SCONST(3))
  #define STk_void	((SCM) MAKE_SCONST(4))
)

                                         -Richard