in reply to Re^2: Knowing when variables change?
in thread Knowing when variables change?

tie would affect performance of the script, especially if you tie every variable in it. Plus, there is no way to automatically tie every variable either. The problem is lexicals; you can't override my to coerce it into calling the tie constructor. So you'll have to manually tie every variable you're interested in. If you're interested in every variable, tie them all. But expect that to be a drag on the script's performance. The performance hit comes from the fact that variable access will now have all this extra work attached to it. You can't escape that.

One strategy is to use a debug flag. If the script is invoked with the -tie flag (for example), your code would go ahead and tie every variable that you set up to do so. And if the script isn't invoked with the -tie flag, your script would skip the code that ties the variables you need to watch. That's just a matter of you coming up with the proper logic to make that happen.

Is it possible that your problem has some other solution? What exactly are you really trying to do, that is requiring you to watch every single variable in the script?


Dave

Replies are listed 'Best First'.
Re^4: Knowing when variables change?
by Anonymous Monk on Oct 24, 2004 at 17:09 UTC
    Do you happen to have benchmarks of how long tie takes?

    I'm displaying "offline" reports of scripts.
    I want to display a small JavaScript hover-thingie which should display all of the variables' content.
    I do want to show this for all variables, I don't know if I really want to tie all variables.
    I would use PadWalker to know what lexical variables are declared.
    Thanks.