unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Lambda efficiency
@ 2010-06-22 19:18 Michael Lucy
  2010-06-22 19:30 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Lucy @ 2010-06-22 19:18 UTC (permalink / raw)
  To: guile-devel

Hey,

I'm generating some code, and I was wondering if:
((lambda (x) (* x 2)) 3)
is significantly less efficient than:
(* 3 2)
or if the Guile compiler will take care of that for me (the expression
is going to be evaluated a lot).



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

* Re: Lambda efficiency
  2010-06-22 19:18 Lambda efficiency Michael Lucy
@ 2010-06-22 19:30 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2010-06-22 19:30 UTC (permalink / raw)
  To: Michael Lucy; +Cc: guile-devel

Heya,

On Tue 22 Jun 2010 21:18, Michael Lucy <MichaelGLucy@Gmail.com> writes:

> I'm generating some code, and I was wondering if:
> ((lambda (x) (* x 2)) 3)
> is significantly less efficient than:
> (* 3 2)

((lambda (x) y) z) is reduced to (let ((x z)) y) at compile-time. We
don't inline x yet, though we will soon.

Verily:

scheme@(guile-user)> ,c ((lambda (x) (* x 2)) 3)
Disassembly of #<objcode 8b98968>:

   0    (assert-nargs-ee/locals 8)      
   2    (make-int8 3)                   ;; 3
   4    (local-set 0)                   
   6    (local-ref 0)                   
   8    (make-int8 2)                   ;; 2
  10    (mul)                           
  11    (return)                        

scheme@(guile-user)> ,c (* 2 3)
Disassembly of #<objcode 8eac318>:

   0    (assert-nargs-ee/locals 0)      
   2    (make-int8 2)                   ;; 2
   4    (make-int8 3)                   ;; 3
   6    (mul)                           
   7    (return)                        

Andy
-- 
http://wingolog.org/



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

end of thread, other threads:[~2010-06-22 19:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-22 19:18 Lambda efficiency Michael Lucy
2010-06-22 19:30 ` Andy Wingo

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