-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: more scope lawyering (re #40238) #40394
Conversation
I've long thought about completely re-imagining this entire chapter... and completely removing the word "variable" in favor of "name." I've found the latter vocabulary very helpful in teaching beginners Julia's behaviors, particularly when it comes to argument passing. I've found "variable" comes along with heavy baggage of a "box" mental model (that's often somewhat broken) and is rather ill-placed in Julia where we can't take the address of a binding or pass by reference to a name. |
Well, I fear that this text is now mind-numbingly complete. I have a hard time imagining that people can read this and understand what it means but at least it doesn't gloss over any details. |
I feel like a document that explains what scope is and how to think about it might be what most people need. They're not actually confused about Julia's scope rules so much as the concept of scope in general. The confusion about Julia's scope rules is just the local manifestation of that general confusion applied to the language that they happen to be currently trying to program in. |
About the last new sentence ("which may surprise users coming from Python where assignment in an inner function creates a new local unless the variable is explictly declared to be non-local"): this might be removed from here to make it a bit shorter, and add a comment about it in the section of Noteworthy differences from Python |
I agree this isn't the most appropriate place to mention differences from Python (why only Python and not other languages?), but the reason I included that comment was that the first part of the sentence seemed poorly motivated otherwise: i.e. why is it worth noting that "this applies to variables assigned in inner functions"? It's only worth noting if some people might expect otherwise, and people would only expect otherwise if they have experience with languages where that's not the case, in which case it seems perverse to not mention at least one such language by name. |
1cd8068
to
3b9c73f
Compare
Added a variant of |
Much more than this and we're writing a book about how lexical scope works in general rather than a chapter about how it works in Julia specifically. Closes #40238.