guile-devel
[Top][All Lists]
Advanced

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

Re: Lambda efficiency


From: Andy Wingo
Subject: Re: Lambda efficiency
Date: Tue, 22 Jun 2010 21:30:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux)

Heya,

On Tue 22 Jun 2010 21:18, Michael Lucy <address@hidden> 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/



reply via email to

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