Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Assuming the author is in the comments, the paragraph about data immutability is wrong. Integers are immutable in Python, when you created the lambda the name x is in its closure. When you assign to it it changes where the name is pointing to. Elixir does something wild and completely different. When you assign x that second time at that moment is creates a new variable behind the scenes and you transparently start using that one when you now refer to x in that scope. So lambda has a reference to x@0 and your outer scope has a reference to x@1.


Thanks for pointing that out, I knew it was a closure because of the Elixir in Action book, and the example's explanation threw me off balance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: