|
|
|
#17 |
|
Messages: n/a
Hébergeur: |
David A. Black wrote:
> Hi -- > > On Mon, 17 Sep 2007, 7stud -- wrote: > >> >> | >> symbol_obj >> id:2545934 >> ^ ^ ^ >> | | | >> s1 s2 s3 > > If the top arrow means that the symbol :hello contains a reference to > a string "hello", in the same way that s1-3 are bound to references to > :hello, then I would say that's the error. Yes, the arrows stand for references. > A symbol can be converted > to a string, such that the string represents the same sequence of > characters as the symbol; but the symbol is not a reference to a > string object. > Interesting and puzzling. The symbol object has no member variable that is a pointer to a string? As a consequence, the string object might never exist in memory? -- Posted via http://www.ruby-forum.com/. |
|
|
|
#18 |
|
Messages: n/a
Hébergeur: |
On 9/17/07, 7stud -- <dolgun@excite.com> wrote:
> David A. Black wrote: > > Hi -- > > > > On Mon, 17 Sep 2007, 7stud -- wrote: > > > >> > >> | > >> symbol_obj > >> id:2545934 > >> ^ ^ ^ > >> | | | > >> s1 s2 s3 > > > > If the top arrow means that the symbol :hello contains a reference to > > a string "hello", in the same way that s1-3 are bound to references to > > :hello, then I would say that's the error. > > Yes, the arrows stand for references. > > > A symbol can be converted > > to a string, such that the string represents the same sequence of > > characters as the symbol; but the symbol is not a reference to a > > string object. > > > > Interesting and puzzling. The symbol object has no member variable that > is a pointer to a string? As a consequence, the string object might > never exist in memory? The exact situation is implementation dependent and the implementation of symbols in Ruby has changed over time. In general the interpreter/vm needs to be able to obtain the string representation of a symbol, and also obtain/create a symbol from an arbitrary string. There are several ways to achieve these requirements. I guess that it's literally true that in a minimal program like :symbol A string object "Symbol" might never exist in memory, but SOME representation of that sequence of characters almost certainly does. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ |
|
![]() |
| Outils de la discussion | |
|
|