On Mar 19, 2004, at 7:17 AM, Joe Marshall wrote:
> Richard Cleis <rcleis at mac.com> writes:
>>> 1) Do these two generate the same code?
>> They might. Or not. They do the same thing.
>>> 2) Which one best contains the spirit of scheme?
>>>> (define a-function-using-defines
>> (lambda ()
>> (define one-variable 3)
>> (define another-variable 4)
>> (list one-variable another-variable))) ; edi
>>>> (define a-function-using-let-list
>> (lambda ()
>> (let ((one-variable 3)
>> (another-variable 4) )
>> (list one-variable another-variable)))) ; edit
>> I have a strong preference for the latter for a couple of reasons.
>> The LET expression cannot have mutually recursive bindings, so I know
> without further inspection that no variable being bound in the LET
> depends on any of the others.
>> The internal DEFINE is equivalent to a LETREC, and LETREC exists
> to facilitate defining mutually recursive functions and data
> structures. When I see one, I tend to expect that earlier definitions
> may depend on later ones.
>> But that's just my opinion.
>Thanks. I am diving into the scheme pool before anyone else in my
group, now some are beginning to ask questions like these. I have been
using 'define only when absolutely necessary, but have no rigorous
explanation.
rac