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

Re: no constants please



    > From: Michael Sperber <sperber@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

    > Tom> SCHEME_FALSE, SCHEME_TRUE, SCHEME_NULL, and
    > Tom> SCHEME_UNSPECIFIC should be functions, not constants:

    > Why?

    > Tom> [...] because, you never know, those constants might be
    > Tom> heap allocated.

    > That, AFAICS, doesn't mandate the above.

Perhaps it would be clearer if I said that those constants may be
_newly_ heap allocated.

It isn't GC-safe to return values which may be unprotected from GC.

If you were to use JNI-style allocated handles for everything then
those macros could be written as specified.  I think the drawbacks to
that approach outweigh this and other minor syntactic advantages,
however.

Anyway, why is it important to write them that way?  You can't use
them with == or !=.  Doing it your way they're just "different" from
every other value in the system apparently because of a non-portable
bias towards assuming that they are implemented as immediate values.

-t