unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* goops speedups
@ 2020-10-10 15:16 Stefan Israelsson Tampe
  2020-10-10 20:12 ` Linus Björnstam
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Israelsson Tampe @ 2020-10-10 15:16 UTC (permalink / raw)
  To: Guile User

Dear all,

Consider the following code

(define (f x)
   (let lp ((i 0) (s 0))
       (if (< i (len x))
           (lp (+ i 1) (+ (get x i) s))
           s)))

Not an uncommon code. The problem is you should be able speed up the loop
if len and get is generalized procedures by doing the dispatch once like
this

(define (f x)
   (let ((-len (find-dispatch len x))
          (-get (find-dispatch get x)))
     (let lp ((i 0) (s 0))
         (if (< i (-len x))
             (lp (+ i 1) (+ (-get x i) s))
              s))))

The question is if we have such an interface or similar or if we should
request that we get such a feature from the guile overlords.

Regards
Stefan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-10 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 15:16 goops speedups Stefan Israelsson Tampe
2020-10-10 20:12 ` Linus Björnstam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).