On Sat, Aug 27, 2011 at 10:24 AM, Brian Goslinga
wrote:
> For example, is this piece of code legal?
> (let [x 5]
> (* x 2))
> Currently it is. However, if we restricted the shadowing of locals, it
> may or may not be -- you cannot tell unless you look at the
> surrounding context.
So, the restri
On Sat, Aug 27, 2011 at 6:05 AM, Alan Malloy wrote:
> Stylistically, it's often not very nice to rebind x a number of times;
> it's better to choose descriptive names for the intermediate steps.
> But there are certainly times occasions where using the same name can
> clarify meaning: for example,
Hi Terje,
The `let` form allows rebinding of symbols, which is not the same as
mutability. In the form
(let [x 1
y 2
x (+ x y)]
x)
the value of `x` does not change, rather the third line creates a new
binding for `x`. The difference may seem trivial, but most func
On Aug 27, 4:37 am, Terje Dahl wrote:
> I was surprised to discover that the following was possible:
>
> (let [
> x 1
> y 2
> x (+ x y) ]
> x )
>
> This runs and returns 3!
>
> This feels an awful lot like variables and procedural programming.
> It is left up to the devel
Perhaps you'd be more comfortable considering this equivalent syntax:
(let [x 1]
(let [y 2]
(let [x (+ x y)]
x)))
In principle, the multiple-binding let is transformed to this version
and thus has identical semantics; in practice, the compiler does
something more efficient but equival
I was surprised to discover that the following was possible:
(let [
x 1
y 2
x (+ x y) ]
x )
This runs and returns 3!
This feels an awful lot like variables and procedural programming.
It is left up to the developer to not resetting a "variable" - by
convention - and if