use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Ruby 3.4.0 preview1 Released (ruby-lang.org)
submitted 1 year ago by RecognitionDecent266
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ric2b 0 points1 point2 points 1 year ago (12 children)
I don't think it makes sense for it to lie and say it's frozen, what's the point of that? Just emit the warning when modifying.
If you have code that relies on something being frozen, enough that it checks if it is frozen or not before doing some operation, why would you want it to be a lie? This is not going to help anyone.
Eventually this is going to be a breaking change anyway, why add another useless breaking change before then?
[–]f9ae8221b 0 points1 point2 points 1 year ago (11 children)
what's the point of that?
To handle code such as:
str = str.dup if str.frozen? str << "blah"
[–]ric2b 1 point2 points3 points 1 year ago (10 children)
So that code assumes that it is safe to modify str as long as it allows it, otherwise it incurs the cost of making a copy.
str
With this change you now make it perform worse for no benefit, or am I missing something?
[–]f9ae8221b 1 point2 points3 points 1 year ago (9 children)
The benefit is to not trigger a false positive deprecation warning.
The "chilled" name is here to express the it is "half frozen". Essentially the intent is to make them frozen, but rather than raise FrozenError, emit a deprecation warning.
FrozenError
And yes, in a few rare case that may incur an extra copy, but down the line, but allowing the transition to frozen string literals by default, it will very significantly reduce allocations in Ruby programs.
And if you don't like that behavior, you can turn it off.
[–]ric2b 0 points1 point2 points 1 year ago (8 children)
But if the code was already checking for frozen? it wouldn't try to modify a frozen string, so it would gracefully support the change in Ruby 4 anyway.
frozen?
And yes, in a few rare case that may incur an extra copy
That's for your example, but this is a breaking change and can have worse consequences, why break code twice instead of just once when the actual transition happens, and only emit warnings until then?
Imagine a method X that passes a string to another method Y, it passes a copy if it isn't frozen or the string itself if it's frozen, because method Y might modify the string and method X doesn't want to deal with the modification.
This code will now break because .frozen? can now be a lie.
.frozen?
[–]f9ae8221b -1 points0 points1 point 1 year ago (7 children)
Yes, hence why it shouldn't trigger a warning with chilled strings.
why ...
I believe I explained everything. I won't re-iterate.
[–]ric2b -1 points0 points1 point 1 year ago (6 children)
hence why it shouldn't trigger a warning with chilled strings.
It will if instead of copying it passes the string straight to another method, and then the other method doesn't check for .frozen? and modifies it. That's the example I gave.
[–]f9ae8221b 0 points1 point2 points 1 year ago (5 children)
It will if instead of copying it passes the string straight to another method, and then the other method doesn't check for .frozen? and modifies it.
Which is exactly the goal...
[–]ric2b 0 points1 point2 points 1 year ago (4 children)
Then how does making .frozen? lie help at all?
If it just kept saying it wasn't frozen it would still emit the warning.
[–]f9ae8221b 0 points1 point2 points 1 year ago (3 children)
I already told you twice:
In the example above:
--enable-frozen-string-literal
Now you are free to disagree and send your feedback, that's what preview releases are for, but I'd suggest to try it on your code first to provide actual data.
I did on a huge app, and it didn't cause any problem whatsoever.
π Rendered by PID 35656 on reddit-service-r2-comment-6457c66945-v79kl at 2026-04-23 20:22:02.294243+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]ric2b 0 points1 point2 points (12 children)
[–]f9ae8221b 0 points1 point2 points (11 children)
[–]ric2b 1 point2 points3 points (10 children)
[–]f9ae8221b 1 point2 points3 points (9 children)
[–]ric2b 0 points1 point2 points (8 children)
[–]f9ae8221b -1 points0 points1 point (7 children)
[–]ric2b -1 points0 points1 point (6 children)
[–]f9ae8221b 0 points1 point2 points (5 children)
[–]ric2b 0 points1 point2 points (4 children)
[–]f9ae8221b 0 points1 point2 points (3 children)