From: Marc-Andre Lafortune Date: 2021-01-31T12:21:50-05:00 Subject: [ruby-core:102337] Re: eliminating symbols... --===============1620018276== Content-Type: multipart/alternative; boundary="000000000000b5e94c05ba357975" --000000000000b5e94c05ba357975 Content-Type: text/plain; charset="UTF-8" Agree with @eregon. In my mind there is a big semantic difference between a Symbol and a String. Symbols are identifiers meant for developers and the machine. A program that needs to run in a multi-language environment, all strings should (ideally) be localized, while no symbols will. I probably shouldn't even be arguing on the merits of the idea; the incompatibility alone is reason enough to not change this. On Sun, Jan 31, 2021 at 9:41 AM Benoit Daloze wrote: > I believe Symbols have a significant performance advantages compared to > regular String, i.e., they can always be compared by identity. > However, if a String would know if it's "interned" in the fstring table, > then such optimization could be done for fstring Strings too (if both > operands are fstring Strings). > > IMHO, learning the difference between String and Symbol is part of > learning Ruby. > Symbol are identifiers or enums, String is basically just data. > > On Sun, Jan 31, 2021 at 2:13 AM Eric Wong wrote: > >> Was just catching up with some of the HashWithIndifferentAccess >> discussion at >> https://bugs.ruby-lang.org/issues/17472 >> >> Could a magic comment (e.g. "# symbols_are_strings: true") >> make :foo a shorthand for a frozen 'foo' String? >> >> If you turn your head sideways, the : character can look like '' >> >> That would provide a migration path which would allow reducing >> the use of Symbols and maybe get rid of it down-the-line(*). >> >> Implementation-wise, every symbol already has a frozen string >> associated with it, so there's no extra memory cost. >> >> >> (*) I now consider Symbols a mistake of the Ruby language design >> and they should've been only an implementation detail. This >> is even more so with GC-able symbols nowadays. But maybe my >> brain is infected by too much Perl5 :P >> >> Unsubscribe: >> >> > > Unsubscribe: > > --000000000000b5e94c05ba357975 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Agree with=C2=A0@eregon.

In my mind the= re is a big semantic difference between a Symbol and a String. Symbols are = identifiers meant for developers=C2=A0and the machine. A program that needs= to run in a multi-language environment, all strings should (ideally) be lo= calized, while no symbols will.

I probably shouldn= 't even be arguing on the=C2=A0merits of the idea; the incompatibility= =C2=A0alone=C2=A0is reason enough to not change this.

On Sun, Jan = 31, 2021 at 9:41 AM Benoit Daloze <eregontp@gmail.com> wrote:
I believe Symbols have a significant pe= rformance advantages compared to regular String, i.e., they can=C2=A0always= be compared by identity.
However, if a String would know if it's &= quot;interned" in the fstring table, then such optimization could be d= one for fstring Strings too (if both operands are fstring Strings).

IMHO, learning the difference between String and Symbol i= s part of learning Ruby.
Symbol are identifiers or enums, String = is basically just data.

On Sun, Jan 31, 2021 at 2:13 AM Eric Wong <= ;normalperson@yh= bt.net> wrote:
Was just catching up with some of the HashWithIndifferentAccess discu= ssion at
https://bugs.ruby-lang.org/issues/17472

Could a magic comment (e.g. "# symbols_are_strings: true")
make :foo a shorthand for a frozen 'foo' String?

If you turn your head sideways, the : character can look like ''
That would provide a migration path which would allow reducing
the use of Symbols and maybe get rid of it down-the-line(*).

Implementation-wise, every symbol already has a frozen string
associated with it, so there's no extra memory cost.


(*) I now consider Symbols a mistake of the Ruby language design
=C2=A0 =C2=A0 and they should've been only an implementation detail.=C2= =A0 This
=C2=A0 =C2=A0 is even more so with GC-able symbols nowadays.=C2=A0 But mayb= e my
=C2=A0 =C2=A0 brain is infected by too much Perl5 :P

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscribe= >
<http://lists.ruby-lang.org/cgi-bin/m= ailman/options/ruby-core>

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscribe= >
<http://lists.ruby-lang.org/cgi-bin/m= ailman/options/ruby-core>
--000000000000b5e94c05ba357975-- --===============1620018276== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Unsubscribe: --===============1620018276==--