-
Notifications
You must be signed in to change notification settings - Fork 140
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
Change frozen_string_literal
to be a tri-state
#2577
Conversation
Yeah I'd prefer a uint8_t since it has multiple states as opposed to two bools if you don't mind |
Alright, doing that then. |
50f2396
to
b7cbf70
Compare
frozen_string_literal: false
frozen_string_literal
to be a tri-state
b7cbf70
to
8400a92
Compare
a22e555
to
81cbb63
Compare
Alright I think I fixed all issues. I changed Also I use |
Okay I'm trying to get my head around how to compile this and I'm now not so sure about these changes. I'm going to lay out a bunch of information, and maybe you can find where I'm missing something? Here's a table of the various combinations of options in Ruby:
We need to map these options from the combination of From the table above, it seems like not specifying a CLI option and passing So I guess what I'm saying is I'm not understanding what we're changing here. |
Alright, I'll try to explain. So first for the context, I'm working on changing the default value of Which I'm implementing in Shopify/ruby#549 for now. So MRI now needs to know if a literal string is Does that make sense now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I think I understand now, thanks for the explanation. In this case I think I understand that the table is now:
So if I understand your proposal correctly, it would change the table to be:
# frozen_string_literal |
--{enable,disable}-frozen-string-literal |
"" |
---|---|---|
unspecified | unspecified | chilled |
false |
unspecified | mutable |
true |
unspecified | frozen |
unspecified | disable |
mutable |
false |
disable |
mutable |
true |
disable |
frozen |
unspecified | enable |
frozen |
false |
enable |
mutable |
true |
enable |
frozen |
And for compiling we should check:
- if
FROZEN
-> frozen - if
MUTABLE
-> mutable - else -> chilled
Is that right?
I've added a couple of minor comments on the code itself.
587f928
to
6a6fe85
Compare
An explicit `false` is not equivalent to the comment being missing, because the default can be switched with a runtime flag: ```bash $ ruby --enable-frozen-string-literal -e 'p "foo".frozen?' true ```
6a6fe85
to
4660f58
Compare
An explicit
false
is not equivalent to the comment being missing, because the default can be switched with a runtime flag:NB: I chose to make it a second boolean flag as I'm not sure what the API compatibility guarantees are, but maybe a three state enum might be better?
@kddnewton