elixir-lang / elixir-lang.github.com

Website for Elixir
elixir-lang.org
354 stars 822 forks source link

Documentation doesn't explain scoping rules in Elixir #1526

Closed a8t closed 3 years ago

a8t commented 3 years ago

Hi, let me know if I should move or add this issue to another repo.

I think it would be good if the Getting Started guide included an explanation of scoping rules in Elixir.

This resource is quite comprehensive: https://elixir-lang.readthedocs.io/en/latest/technical/scoping.html It appears that no comparable 'official' resource is available. To me, this is an oversight – variable scoping seems like a fundamental aspect of a language.

Should we add some of that content into the Getting Started?

(cc @axelson with whom this came up in conversation)

josevalim commented 3 years ago

I would say scoping is outside of a Getting Started guide and more of an advanced topic. I believe we mention the rules as we introduce the constructs but we could have a unified guide either in the meta programming guides or in Elixir detailed pages.

a8t commented 3 years ago

Actually yes, as you said, it's mentioned briefly here: https://elixir-lang.org/getting-started/try-catch-and-rescue.html#variables-scope

Just so I'm sure, by Elixir detailed pages, do you mean one of these?

edit - it's also mentioned here, sorry. I actually think this is sufficient! but maybe a little hard to find.

josevalim commented 3 years ago

Yes, I was sure we mentioned it on if/unless too. I think try/catch could be rewritten though, it behaves the same as any other construct and it is written as if it wasn’t.

josevalim commented 3 years ago

So I think I will improve the docs for try/catch and close it. :) thanks for the feedback!

a8t commented 3 years ago

Great, thanks José!