At 12:35 PM 8/4/00 -0400, Chaim Frenkel wrote:
> >>>>> "DS" == Dan Sugalski <[EMAIL PROTECTED]> writes:
>
>DS> The language semantics of tie strongly impact the internals. tie() is
>DS> basically a declaration that the rules are completely different (and
>DS> unknown at compile time) for the tied variable. Shoots down 
>optimization a
>DS> bunch, since access to a tied varible has to be treated as a function 
>call
>DS> rather than as access to data with known behaviours.
>
>Why?
>
>The vtbl for a tied variable would do all the work. Either the pointer
>is to a springboard into perl code, or internal code, or the XS
>replacement code.

It's more than that. If the optimizer does code flow, it can know that 
$foo's been assigned an integer, for example, and maybe even that that 
variable's never been changed, so this:

   $foo = 12;
   $bar = something();
   $bar = $foo;

could work out to:

   $foo = $bar = 12;
   something();

Where if you tie, we have *no* idea what you're doing. This:

   tie $foo, SomeModule;
   $foo = 12;

could well reboot some server in outer mongolia for all we know. Tied 
variable access counts as a function call, which smacks optimization all by 
itself.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to