Email list hosting service & mailing list manager


Re: no constants please Tom Lord 31 Dec 2003 19:03 UTC

    > From: Richard Kelsey <xxxxxx@s48.org>

    > 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?)

Something about that question bugs me.  If you were working on UFFI
for CL I could understand that -- you have a bunch of mature and
comprehensive implementations, competing with one another in some
sense, and they all agree to give the users an FFI that is portable
among them.  In the Scheme world, I think we are not so blessed.  We
have mature but not comprehensive implementations; comprehensive but
not mature; many specialized implementations at varying degrees of
maturity; and active contemplation and activity exploring various
implementation strategies.  My hope for your SRFI is that it's less
reactionary to what's there and more anticipatory of what's
forseeable.

Reviewing and commenting on specifics:

Ken pointed out implementations which use heap allocated objects for
constants.

Copy-or-update-on-read collection strategy also throws a wrench into
the naked use of == as EQ?.

UNSPECIFIC is an interesting case.  Certainly, at least, it is not
hard to imagine wanting to freshly allocate UNSPECIFIC so that no two
separately produced instances of it are EQ?.  That seems to be similar
to or part of where Bear is going.

If UNSPECIFIC is a member of a disjoint type, regardless of whether it
is freshly allocated, surely some systems will want it to be an error
to test it for EQ-ness to anything: so == is not EQ? in that case.

More generally, an FFI must solve two problems for _other_ values,
namely, what is the interface convention for an FFI entry point that
can produce a scheme value and what is the interface convention for an
FFI entry point that accepts scheme values?   What you propose
concerning EQ? and the three or four constants is that, whatever the
general rule is in the FFI, for that test and these values, there is
an exception.

What is the value of that irregularity?   I see none.

If, on the other hand, you treat EQ? like any other function and those
values like any other way of getting back a scheme value from the FFI
entry points, then you never have to fret over questions like those
you've raised above.

-t