I've discovered two more tests that can be optimized using the same bit masking tricks: scm_is_bool and scm_is_bool_or_lisp_nil (newly created). Since SCM_BOOL_F and SCM_BOOL_T differ by only one bit, that one is easy. The other one can be implemented the same way as scm_is_lisp_false in my last proposal, by making IFLAG 5 another never-to-be-used value. That way, IFLAGS 0/1/4/5 (#f %nil #t dont-use-2) are all the same except for two bit positions.
So I was thinking that scm_is_bool and scm_is_bool_or_lisp_nil could be implemented as macros, which are as fast and as compact as testing for boolean truth. What do you think? Also, since writing my last email, I've realized that my testing macros need to use SCM_UNPACK. I'm currently in the process of preparing a patch. As part of that process, I'm reviewing all uses of the affected macros, and evaluating for each use case how %nil should be handled. In order to remain flexible with regards my other pending proposal, I'm forking macros into two variants: one which checks for %nil when appropriate, and one which doesn't. We can decide what their names should be later. I found one thorny use of scm_is_bool and scm_is_null, and request your collective wisdom: scm_class_of() in goops.c tries to determine the class of a scheme value. If scm_is_bool returns true, it's classified as scm_class_boolean, and if scm_is_null returns true, it's classified as scm_class_null. Right now, that code doesn't consider %nil at all. How do you all think %nil should be handled by goops? It seems to me that it would be nice to try to support %nil transparently when possible. Mark