Re: Well I did it! (variable_id, etc..)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Andy Serpa wrote:
> 
> Robert Craig wrote:
> > 
> > What it was actually doing internally is something like:
> > 
> >    temp1 = val[a]
> >    temp2 = val[b]
> >    lhs_check_subs(temp1, temp2)
> > 
> 
> So I can understand, it uses these temps because the val is subscripted?  

Yes.

> And when
> you replace it with x it just uses x?  

Yes.

> Or does it then create a temp with a reference
> to x for the lhs_check_subs() call?
 
No temp will be used, but an extra ref will be put on the 
value of x during the call (in case the routine wants to modify the
value via it's parameter that receives the value of x).
It will be removed at the end of the call.
At the end of each routine call, all temps used by that routine
are "de-ref'd". The key thing here, is that I am able to
explicitly overwrite the value of x, and lose the ref that x
has to val[a]. When temp1 had a ref to val[a], I couldn't
explicitly kill that ref. I just had to hope that temp1
would be overwritten by some expression before I did the
LHS subscripting operation.

I wouldn't expect the average Euphoria user to be
concerned about internal reference counts. Usually
Euphoria does a reasonable job of handling these things.
This case is unusual. For instance, it wouldn't happen with a single
level of subscripting, because then temp1 would not be
required - val would be passed directly. Temps are typically needed
to hold expression results (val[a]), not copies of whole 
variables (val).

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu