did_you_mean icon indicating copy to clipboard operation
did_you_mean copied to clipboard

Suggest global variables

Open styd opened this issue 8 years ago • 7 comments

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.

styd avatar Nov 19 '17 16:11 styd

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 avatar Nov 19 '17 18:11 yuki24

@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.

styd avatar Nov 20 '17 06:11 styd

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.

yuki24 avatar Nov 23 '17 21:11 yuki24

Hi, @yuki24. How did the Ruby committer meeting go? Have you guys decided anything about the global variables?

styd avatar Jan 10 '18 15:01 styd

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.

yuki24 avatar Jan 10 '18 18:01 yuki24

Ah, I see. No problem. I already expected that it won't be easy to decide this.

styd avatar Jan 10 '18 23:01 styd