This is the mail archive of the 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.

Ken Raeburn wrote:

> Dirk Herrmann <> writes:
> > > > 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:
> Without actually taking a closer look at any of these instances, I
> wonder if converting to a sequence of 'if' tests would present much
> difficulty?  One thing I've been doing with guile-emacs has been
> converting from:
>         switch (foo) {
>         case This:
>                 ...
>         case That:
>                 ...
>         }
> to
>         if (EQ (foo, This)) {
>                 ...
>         } else if (EQ (foo, That)) {
>                 ...
>         } ...
> which, if the compiler is doing its job, should have roughly the same
> performance in the case where the tests still boil down to testing a
> field against a constant.  Even if they don't generate the same code,
> the relative performance of the switch versus if-sequence is going to
> be compiler- and usage-dependent anyways.

Telford Tendys wrote:

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

Can somebody confirm that the compilers are really doing their job right,
possibly based on assembly code output from the compilers?  It may well
be:  If not compiling with strict typing, the if-else-if... chain would
actually become a sequence of comparisons with a constant.  If compiling
with strict typing, it probably wouldn't, but performance with strict
typing is expected to be horrible anyway.

> #if __GNUC__ >= 2
> #define scm_pack(b) ({ scm_bits_t __b = (b); SCM __s; __s.n.n = __b; __s; })
> #endif

Another bit of GNU magic.  I'm not sure whether it makes sense to support
this, except people would like to _run_ code that was compiled with strict

Thanks for your comments.

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