Mark H Weaver <m...@netris.org> writes:

> Below is a proposal for how to make boolean tests and end-of-list
> tests faster and more compact, by renumbering the representations for
> SCM_ELISP_NIL, SCM_EOL, SCM_UNDEFINED, and SCM_EOF_VAL.

Interesting.  I haven't looked at every detail but I'm happy to go
along with Andy's impression.

Assuming you are planning to work on the code changes for this, we
will need copyright assignment papers from you.  Will that be OK?

> along with a regression test somewhere to complain unless both of the
> XOR subexpressions above are powers of two:
>
>       #define IS_POWER_OF_TWO(x)             ((x) & ((x)-1) == 0)
>       #define DIFFER_BY_ONLY_ONE_BIT(x, y)   IS_POWER_OF_TWO((x)^(y))
>       
>       if ( ! DIFFER_BY_ONLY_ONE_BIT(SCM_ELISP_NIL, SCM_BOOL_F) )
>         complain();
>       if ( ! DIFFER_BY_ONLY_ONE_BIT(SCM_ELISP_NIL, SCM_EOL) )
>         complain();

There are ways of writing compile time asserts; see
http://www.jaggersoft.com/pubs/CVu11_3.html for some.  I don't know
how portable these all are, but at work we use the case label one, and
that seems to be good on common platforms.

Regards,
        Neil


Reply via email to