PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Newbie
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Newbie

Réponse
 
LinkBack Outils de la discussion
Vieux 17/09/2007, 17h08   #17
7stud --
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie

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

  Réponse avec citation
Vieux 17/09/2007, 17h33   #18
Rick DeNatale
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie

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/

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h39.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07457 seconds with 10 queries