swannodette / lt-cljs-tutorial

A ClojureScript Programming Language Tutorial for Light Table Users
MIT License
863 stars 123 forks source link

defn functions inside let bindings are still available outside #26

Closed DjebbZ closed 10 years ago

DjebbZ commented 10 years ago

I think this point is important, since in Javascript when you define a function inside a scope, this function is only available in this scope. Here ClojureScript allows a function defined in a let bindings (concept close to the scope) to be available outside the let. Not sure my change in the code nor this very comment is clear, but for a ClojureScript beginner like familiar with Javascript I felt this needed to be explained and explicit.

swannodette commented 10 years ago

This is an important point, thanks!

swannodette commented 10 years ago

It needs a little bit more clarification which I will add.

DjebbZ commented 10 years ago

I also tried something else, maybe silly, of defining functions inside of a function definition, i.e. defn inside another defn. The compiler didn't like this, but the equivalent in javascript is perfectly legit. Maybe you could add a note about this ? Also I don't understand why it doesn't work in CLJS.

swannodette commented 10 years ago

I actually already added a note and explanation about that too.

DjebbZ commented 10 years ago

Sorry, I should really read the whole tutorial and ask afterwards. By the way, this tutorial rocks !