Thanks a lot for such a clear explanation. Now it all seems to fall in
place (: and obviously, obvious :).
----- warm regards,
LFTLMFY (: Looking Forward To Learning More From You, that is :)
Atul
Michael Fowler <[EMAIL PROTECTED]>
09/20/01 01:02 PM
To: [EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
Subject: Re: autovivification of typeglobs
On Thu, Sep 20, 2001 at 11:37:50AM -0500, [EMAIL PROTECTED] wrote:
> I think you lost the context.
I was afraid of that.
> My question is not whether %$$self and self are same ( They are not and
> %$this was never a point of debate ). I wanted just the explanation of
> using %$$self in the *** context of *** autovivifying typeglobs. What I
> really don't understand is how to interpret the %$$self ( or @$$self
etc.
> ), w.r.t. typeglobs. I tried to fathom it by reading the Camel but
> somehow miss the obvious (: if it is :)
Wow, I really did miss the conversation. Reading back over it, I see your
original question was regarding the syntax:
open my $self, ...;
and how it's documented that $self is autovivified into a typeglob. It's
magic. Open knows that $self should be a typeglob, so it makes it into
one.
A typeglob is a handle into the symbol table. As you know, @self, $self,
%self, etc. are seperate entities, with seperate values. A glob is a
handle
to all of these data types. Now, when open initializes $self with a
typeglob it's equivalent to the assignment:
$self = \*foo;
Where *foo is, of course, a made up symbol for the purposes of this
example.
Now $self is a reference to a typeglob (note, -reference- to a typeglob,
this is important). If you were to print $self you'd see something like
"GLOB(0x80ffee0)". If you were to print $$self you'd see something like
"*main::foo". Thus, the double-dollar signs to get to the actual value.
To
get to the scalar $foo, you'd have to say $$$self; similarly, %foo,
%$$foo,
and so on.
Does that clear it up? It's a reference to a typeglob and thus needs an
extra level of dereferencing.
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]