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

Re: strings in scheme



Quoting Chris Uzdavinis:
> From what I can tell, there is no behavioral difference between an
> internal definition of a function, and a letrec that creates a lambda
> function.  Both appear to do the same thing, generally speaking.

No difference --- they're compiled exactly the same:

 > (syntax-object->datum (expand '(let () (define x 10) (define y 12) (+ x y))))
 (let-values () (letrec-values (((x) (#%datum . 10)) ((y) (#%datum .
 12))) (#%app (#%top . +) x y)))

 > (syntax-object->datum (expand '(let () (letrec ([x 10][y 12]) (+ x y)))))
 (let-values () (letrec-values (((x) (#%datum . 10)) ((y) (#%datum .
 12))) (#%app (#%top . +) x y)))

>   * why prefer one over the other in situations where both are equally
>     valid.  Is it just personal preference, or is there more to it?

Just preference, or to use a `define'-based macro, such as
`define-struct'.

Matthew