[plt-scheme] to define, or to let

From: Zhu Chongkai (mathematica at citiz.net)
Date: Thu Mar 18 23:58:14 EST 2004

======= 2004-03-19 09:07:17 :=======

>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>I messed up the question; the final expressions should be:
>(list one-variable another-variable)
>
>So what is the difference in the generated code?  Are let-variables 
>created differently than define's ?  It seems that a smart compiler 
>wouldn't create storage at all in the let version (ie, it would just 
>form the list).
>
>rac
>
= = = = = = = = = = = = = = = = = = = =
			
Yes, a smart compiler will treat let without creating storage. 

For example:

(let ((one-variable 3)
      (another-variable 4))
  (list one-variable another-variable))

will first be converted to

((lambda (one-variable another-variable)
   (list one-variable another-variable))
 3 4)

and then the code will be further optimized to 

(list 3 4)


regards, 
Zhu Chongkai

Posted on the users mailing list.