radicle-alpha
radicle-alpha copied to clipboard
(do) should create a lexical scope
Right?
(do
(def foo bar)
...
)
Shouldn't leak foo to its environment. Otherwise we need some sort of let form for creating local definitions.
Yeah, James and I talked about this and I think i agree. (You can in a pinch define and immediately call a lambda for local defs, but that's pretty ugly). The other reason this would be nice because then (modulo macro-like tricks eval) only def adds new bindings.
We do use this feature of do currently to send entire files to chains as one expression, but we also discussed how that too should probably anyhow change.
One downside is that you can't then have a sort of bundling of expressions (a little like transactions) - there's no way to combine two expressions such that either both make it onto a chain or neither, and that no expression comes in between.
Am 03.11.2018 04:38 schrieb "Luke Palmer" [email protected]:
Right?
(do (def foo bar) ... )
Shouldn't leak foo to its environment. Otherwise we need some sort of let form for creating local definitions.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oscoin/radicle/issues/193, or mute the thread https://github.com/notifications/unsubscribe-auth/ABlKmrOFNwPfsFI3s_pUT7I7s2-fDKr6ks5urQ_FgaJpZM4YMnfd .
I think it would be nice but:
- There are still occasions where one might want to sequence some things without creating a new scope (e.g.
(if foo (do (load! "...") (load! "...")) (do ...))). There are probably other examples with eval-redefinitions. - This would make
donot be the same as in clojure.
So I think we could either add let or maybe a scoped-do ((local ...)) (which is essentially just (let [] ...)).