HaloO Matthew,

you wrote:
I wasn't getting hung up on whether $::($varname) should somehow be cached to avoid a dynamic lookup based on the current value of $varname every time. And I assume that if $*Main::foo hadn't been created, assigning to $::($varname) would create it as expected (again, without any caching of $varname).

Here your expectations might be disappointed, sorry.

The non-symbolic form $*Main::foo = 'bar' creates code that
makes sure that the lhs results in a proper scalar container.
The symbolic form might not be so nice and return undef!
Then undef = 'bar' of course let's your program die.

Unfortunately I'm unsure how the runtime interface to
making dynamic namespace entries looks like. Note that
the operator ::= acts at compile time, too.

My guess is that the compiler collects all potential data
items and arranges for auto-vivification and/or autoloading
and even on-the-fly instance composition and such like things.
But for symbolics this is your task.


My confusion initially stemmed from chat on #perl6 about $::Foo and $::('Foo') being Very Different Things - and the fact that there was ever any confusion over whether $::foo was your 'closest' $foo variable or something else.

So to conclude, for reading they amount to the same result but through
different paths. But since the symbolic lookup might result in undef
the behaviour for writing is indeed a Very Different Thing.


@Larry, please correct if I gave wrong advice.
--
TSa (Thomas Sandlaß)


Reply via email to