ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:105744] [Ruby master Feature#11346] New #intern_str or similarly-named method of Symbol to return a cached, frozen string (like "string".freeze)
       [not found] <redmine.issue-11346.20150712191159.9736@ruby-lang.org>
@ 2021-10-21 23:06 ` jeremyevans0 (Jeremy Evans)
  0 siblings, 0 replies; only message in thread
From: jeremyevans0 (Jeremy Evans) @ 2021-10-21 23:06 UTC (permalink / raw)
  To: ruby-core

Issue #11346 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

`Symbol#name` was added in Ruby 3.0 for this.

----------------------------------------
Feature #11346: New #intern_str or similarly-named method of Symbol to return a cached, frozen string (like "string".freeze)
https://bugs.ruby-lang.org/issues/11346#change-94247

* Author: stevej (Steve Jorgensen)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
While I don't think it would be a good idea to change the behavior of the existing Symbol#to_s method as suggested in issue 11066, I think that it would be extremely useful to have some instance method of Symbol to perform that operation.

If such a method is added, it might be nice if String, and maybe even Object offered the same method so the operation could be performed with indifference to the target and so optimizations could be applied to Classes other than just Symbol (e.g. NilClass, TrueClass, FalseClass, and maybe for smallish values of Fixnum).

Perhaps, the new method name would be #intern_str, and if that is added to Object, the default implementation could be something like `to_s.intern_str` which would abide by the contract of always returning the same frozen string object (assuming #to_s does), even though it builds an ordinary string as an intermediate object, so is not optimized.



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-21 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-11346.20150712191159.9736@ruby-lang.org>
2021-10-21 23:06 ` [ruby-core:105744] [Ruby master Feature#11346] New #intern_str or similarly-named method of Symbol to return a cached, frozen string (like "string".freeze) jeremyevans0 (Jeremy Evans)

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