ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
@ 2024-03-19 21:06 Dan0042 (Daniel DeLorme) via ruby-core
  2024-03-20  8:58 ` [ruby-core:117249] " byroot (Jean Boussier) via ruby-core
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Dan0042 (Daniel DeLorme) via ruby-core @ 2024-03-19 21:06 UTC (permalink / raw)
  To: ruby-core; +Cc: Dan0042 (Daniel DeLorme)

Issue #20350 has been reported by Dan0042 (Daniel DeLorme).

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117249] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
@ 2024-03-20  8:58 ` byroot (Jean Boussier) via ruby-core
  2024-03-20 10:52 ` [ruby-core:117255] " Eregon (Benoit Daloze) via ruby-core
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-03-20  8:58 UTC (permalink / raw)
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20350 has been updated by byroot (Jean Boussier).


To provide some data-point. Our monolith runs with https://github.com/Shopify/symbol-fstring, which makes the return value of `Symbol#to_s` frozen without any problem. I think we had to fix a single gem to make it work a few years back, that's it.

That said, while we run a lot of code (700+ transitive gems), that's not necessarily fully representative of the code out there.

Also one major difference with chilled string literals is that you can't just set `RUBYOPT="--disable-frozen-string-literal"` to continue running older code. I guess you could monkey patch `String#to_s` though, and provide that as a gem to make it easy to provide backward compatibility.

All this to say that as a Ruby user, I'd like this change to happen, because `Symbol#to_s` is a major source of allocation, and Ruby performance is very GC dependent.

But as a Ruby committer I think we need to be careful about the rate of deprecation and backward compatibility breaks. On one hand it would sound logical to ship such change at the same time as the change for frozen string literals, but on the other hand it makes the jump bigger and may alienate some users. So it's a fine line to walk.

So I'm positive, but with some reservations.

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107337

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117255] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
  2024-03-20  8:58 ` [ruby-core:117249] " byroot (Jean Boussier) via ruby-core
@ 2024-03-20 10:52 ` Eregon (Benoit Daloze) via ruby-core
  2024-04-03 10:45 ` [ruby-core:117430] " Eregon (Benoit Daloze) via ruby-core
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-03-20 10:52 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #20350 has been updated by Eregon (Benoit Daloze).


+1, I was thinking the same yesterday, that we could revisit `Symbol#to_s` and have a proper deprecation before changing it due to chilled strings landing.

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107348

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117430] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
  2024-03-20  8:58 ` [ruby-core:117249] " byroot (Jean Boussier) via ruby-core
  2024-03-20 10:52 ` [ruby-core:117255] " Eregon (Benoit Daloze) via ruby-core
@ 2024-04-03 10:45 ` Eregon (Benoit Daloze) via ruby-core
  2024-04-16  6:30 ` [ruby-core:117524] " ko1 (Koichi Sasada) via ruby-core
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2024-04-03 10:45 UTC (permalink / raw)
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

Issue #20350 has been updated by Eregon (Benoit Daloze).


I added this to the dev meeting: https://bugs.ruby-lang.org/issues/20336#note-8

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107805

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117524] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
                   ` (2 preceding siblings ...)
  2024-04-03 10:45 ` [ruby-core:117430] " Eregon (Benoit Daloze) via ruby-core
@ 2024-04-16  6:30 ` ko1 (Koichi Sasada) via ruby-core
  2024-04-16  6:41 ` [ruby-core:117526] " byroot (Jean Boussier) via ruby-core
  2024-04-17 22:44 ` [ruby-core:117579] " matz (Yukihiro Matsumoto) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: ko1 (Koichi Sasada) via ruby-core @ 2024-04-16  6:30 UTC (permalink / raw)
  To: ruby-core; +Cc: ko1 (Koichi Sasada)

Issue #20350 has been updated by ko1 (Koichi Sasada).


`Symbol#name` returns frozen string.
It is not enough?



----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107913

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117526] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
                   ` (3 preceding siblings ...)
  2024-04-16  6:30 ` [ruby-core:117524] " ko1 (Koichi Sasada) via ruby-core
@ 2024-04-16  6:41 ` byroot (Jean Boussier) via ruby-core
  2024-04-17 22:44 ` [ruby-core:117579] " matz (Yukihiro Matsumoto) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2024-04-16  6:41 UTC (permalink / raw)
  To: ruby-core; +Cc: byroot (Jean Boussier)

Issue #20350 has been updated by byroot (Jean Boussier).


> `Symbol#name` returns frozen string. It is not enough?

It doesn't work well with duck typing. It's common to have a method that call `to_s` on the argument, and the argument can be a Symbol or another type:

```ruby
def some_method(arg)
  arg = arg.to_s
  # do things
end
```

We can debate the merits of such design of course, but from my experience it's extremely common. Years after `Symbol#name` introduction, `Symbol#to_s` remains visible on production profiles, and running https://github.com/Shopify/symbol-fstring/ still provide a small, but noticeable improvement.

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107915

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:117579] [Ruby master Feature#20350] Return chilled string from Symbol#to_s
  2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
                   ` (4 preceding siblings ...)
  2024-04-16  6:41 ` [ruby-core:117526] " byroot (Jean Boussier) via ruby-core
@ 2024-04-17 22:44 ` matz (Yukihiro Matsumoto) via ruby-core
  5 siblings, 0 replies; 7+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2024-04-17 22:44 UTC (permalink / raw)
  To: ruby-core; +Cc: matz (Yukihiro Matsumoto)

Issue #20350 has been updated by matz (Yukihiro Matsumoto).


I am in favor of experimenting. I am in favor of moving to immutable strings in the future if there are no significant incompatibility issues.

Matz.

----------------------------------------
Feature #20350: Return chilled string from Symbol#to_s
https://bugs.ruby-lang.org/issues/20350#change-107979

* Author: Dan0042 (Daniel DeLorme)
* Status: Open
----------------------------------------
During Ruby 2.7 development there was an attempt to return a frozen string from Symbol#to_s (#16150#note-22)

This had to be rolled back due to incompatibility, but now we have chilled strings (#20205)

Symbol#to_s can safely return a chilled string, giving developers time to fix warnings before switching to a frozen string.




-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-04-17 22:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 21:06 [ruby-core:117240] [Ruby master Feature#20350] Return chilled string from Symbol#to_s Dan0042 (Daniel DeLorme) via ruby-core
2024-03-20  8:58 ` [ruby-core:117249] " byroot (Jean Boussier) via ruby-core
2024-03-20 10:52 ` [ruby-core:117255] " Eregon (Benoit Daloze) via ruby-core
2024-04-03 10:45 ` [ruby-core:117430] " Eregon (Benoit Daloze) via ruby-core
2024-04-16  6:30 ` [ruby-core:117524] " ko1 (Koichi Sasada) via ruby-core
2024-04-16  6:41 ` [ruby-core:117526] " byroot (Jean Boussier) via ruby-core
2024-04-17 22:44 ` [ruby-core:117579] " matz (Yukihiro Matsumoto) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).