4 ms·
> In truth, I've never understood the fuss about `let`. It's taken a huge amount of Hy development effort, but it adds very little My use case is Jupyter noteb
by vaylian 5y ago
> In truth, I've never understood the fuss about `let`. It's taken a huge amount of Hy development effort, but it adds very little
My use case is Jupyter notebooks. With normal Python scoping you quickly accumulate a lot of global variables and you might accidentally use the wrong one. With let-bindings you have variables that clean up after themselves.
- Kodiologist 5y agoI'm not familiar with Jupyter internals, but I think functions would work well for this. Hy allows multi-statement anonymous functions, and you can do stuff like `((fn [] … ))` to define and immediately call the function. One advantage of this over `let` is that it allows old locals to be garbage-collected. If memory isn't an issue, though, `let` should work well.