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

> For example, something as simple as assigning a variable has so much more meaning and functionality than I am used to, thanks to pattern matching.

Functional programming tends to take this even further, by eliminating variable assignment to some degree or another. Different languages approach this differently, for instance:

- Erlang (and I assume this extends to Elixir) asserts a variable's value, rather than assigning it. You can see how this works by attempting to assign another value to the same variable: it will throw an error.

- Clojure (and I assume most lisps?) bind a variable to a symbol, but that only applies to the code that follows; if you access a binding, then rebind it, the previous access will only reference the original value. (Clojure, being impure, has ways around this in a bunch of ways.)



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

Search: