Suggest global variables
Hi, @yuki24. I'm thinking of adding global variables to suggestions.
Previously:
STIN
# NameError: uninitialized constant STIN
# Did you mean? STDIN
# Nice correction. But, this one
stin
# NameError: undefined local variable or method `stin' for main:Object
# Did you mean? String
After this commit:
stin
# NameError: undefined local variable or method `stin' for main:Object
# Did you mean? $stdin
I also cleaned up the list of global variables so that it doesn't start with special characters or numbers that will never trigger NameError in the first place.
Thanks @styd for taking your time and contributing to DYM!
While it is totally reasonable to suggest $stdin, this seems like a tricky case since Matz wants to get rid of global variables entirely, and this would encourage people to use global variables more. I guess what makes more sense is to only suggest preset global variables and exclude user-defined global variables. However, I'm not sure how other Ruby core members feel about this.
Let me escalate this conversation to the Ruby core team. I'll get back to you once we come up with a conclusion.
@yuki24, it's my pleasure. You can close the PR if this is a bad practice. However, I'm really interested in Ruby core team decisions on global variables. Please keep me updated. Thanks.
We are going to discuss global variables in general at the next Ruby committer meeting. We'll get back to you once we come up with a conclusion, but I feel pretty good about this and we should be able to ship this with Ruby 2.5.
Hi, @yuki24. How did the Ruby committer meeting go? Have you guys decided anything about the global variables?
Everything's still in the air and we haven't landed on any conclusion yet. One possibility though is that we may deprecate any symbol global variables like $* and make the rest of the predefined global variables reserved words. If this was really going to happen, then we definitely want this PR in and suggest reserved variable names anywhere. This is why I wanted to keep this PR open as it is today. However, this is probably going to be a year-long conversation, so please don't expect an early conclusion.
Ah, I see. No problem. I already expected that it won't be easy to decide this.