guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Take some lowhanging fruit to speed up R6RS fixnum operation


From: Ludovic Courtès
Subject: Re: [PATCH] Take some lowhanging fruit to speed up R6RS fixnum operations
Date: Thu, 24 Mar 2011 22:51:08 +0100
User-agent: Gnus/5.110013 (No Gnus v0.13) Emacs/23.3 (gnu/linux)

Hi Andreas,

I’m all for your suggestion.

Andreas Rottmann <address@hidden> writes:

> +  (define-syntax define-fxop*
> +    (syntax-rules ()
> +      ((_ name op)
> +       (define name
> +      (case-lambda
> +        ((x y)
> +         (assert-fixnum x y)
> +         (op x y))
> +        (args
> +         (assert-fixnums args)
> +         (apply op args)))))))
> +
> +  (define-fxop* fx=? =)

How about making something like this (untested):

  (define-syntax define-fxop*
    (syntax-rules ()
      ((_ name op)
       (define-syntax name
         (lambda (s)
           (syntax-case s ()
             ((_ x y)
              #'(begin
                  (assert-fixnum x y)
                  (op x y)))
             ((_ args ...)
              #'(apply op args))
             (_ #'op)))))))

This way, there’d be no procedure call involved and ‘=’, ‘+’, etc. would
use the corresponding instruction in the base case.

Thanks,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]