in reply to Re: Re^4: Confirming what we already knew (it's cached)
in thread Confirming what we already knew
When you modify the numeric value (NV) of a scalar, the NOK flag is set and the other flags (IOK, POK) are cleared: that means if we need the NV, we can just grab it (since NOK is true), but if we need the string value (PV, for 'pointer') we need to do a conversion.
When the conversion is done, we also need to distinguish whether the conversion was lossy or not: for example if we use a numeric 1.2 in an integer context, we cache the integer value 1 and set pIOK ('private' integer OK) to avoid the need to recalculate the integer next time we need it, but if it were 1.0 we'd also set IOK.
The Devel::Peek module is very useful for seeing this sort of thing:
Hugoperl -MDevel::Peek -we '$a=1.2;Dump($a);$b="$a";Dump($a)'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re^4: Confirming what we already knew (it's cached)
by BrowserUk (Patriarch) on Mar 05, 2003 at 21:32 UTC | |
by hv (Prior) on Mar 05, 2003 at 21:39 UTC | |
by BrowserUk (Patriarch) on Mar 05, 2003 at 21:52 UTC |