Search Results
6/11/2025, 10:17:15 PM
6/9/2025, 4:01:04 PM
>>105536469
>for some reason multiple `define` in the body is faster than `let*` as well.
You'd have to macroexpand to see what racket is doing, but conceptually
(define (f x)
(define y 2)
(define z 3)
...
(f 1)
extends the local environment but keeps it a single alist:
(((z . 3) (y . 2) (x . 1)) calling-environment)
whereas
(define (g x)
(let* ([y 2])
([z 3])
...
(g 1)
if let* expands into nested lambdas the environment will be extended with multiple alists:
(((z . 3)) ((y . 2)) ((x . 1)) calling-environment)
so looking up x in the body of let* in g could be more expensive than x in the body of f, maybe that's it?
>for some reason multiple `define` in the body is faster than `let*` as well.
You'd have to macroexpand to see what racket is doing, but conceptually
(define (f x)
(define y 2)
(define z 3)
...
(f 1)
extends the local environment but keeps it a single alist:
(((z . 3) (y . 2) (x . 1)) calling-environment)
whereas
(define (g x)
(let* ([y 2])
([z 3])
...
(g 1)
if let* expands into nested lambdas the environment will be extended with multiple alists:
(((z . 3)) ((y . 2)) ((x . 1)) calling-environment)
so looking up x in the body of let* in g could be more expensive than x in the body of f, maybe that's it?
Page 1