This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: So far, so good.


> To solve the 'SCM value as case label' problem, it would be necessary to
> provide a corresponding raw (i. e. unpacked) value for each SCM
> value.  This could look as follows:
> 
> #define SCM_BOOL_T_WORD		SCM_MAKIFLAG (17)
> #define SCM_BOOL_T 		SCM_PACK (SCM_MAKIFLAG (17))

That's not too bad -- they wouldn't be widely visible.

Alother way would be to replace the switch statements with well-designed
trees of if statements (which may actually be faster using a binary
tree of ifs though switch will be faster if the situation lends itself
to a computed goto).

Another way is to ensure that all (or most) of the ``magic'' scheme values
are clustered sequentially and use an enum to describe their relative
position in the cluster like:

enum{ SCM_BOOL_MAGIC }

#define SCM_BOOL_T 		SCM_PACK (SCM_MAKIFLAG (SCM_BOOL_MAGIC))

Then the case labels come out of the enum and the switch head has a
calculation in it to spit out the cluster, then you are pretty much
guaranteeing yourself a computed goto and maximum speed from the switch.

There may still be a few annoying cases that need to be pulled out into
ifs, which it just something that happens.

	- Tel

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]