#numTemps/tempCountOf: is not working correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

#numTemps/tempCountOf: is not working correctly

Hernan Wilkinson-3
 
Hi,
 I came into a weird behavior that I think is an error.
 In pharo/squeak/cuis if you evaluate this:
 
(String>>#romanNumber) numTemps

 It returns 1, but that method has 3 temps. The same happens with other methods like "(SmallInteger>>#printOn:base:length:padded:) numTemps", that return 9 but the method has 8 temps.

 With an interpreter simulator I ran an image, look for String>>#romanNumber and send the #tempCountOf: to the simulator with the romanNumber method as parameter and I got 1, as in the image, instead of 3. So at least #tempCountOf: behavior is consistent with the #numTemps of the image.

 My question is: is that the right behavior? or is it an error?
 It looks like an error to me but I may not know something about how #numTemps work.

 Thanks
 Hernan.

--
Hernán Wilkinson
Agile Software Development, Teaching & Coaching
Phone: +54-011-4893-2057
Twitter: @HernanWilkinson
Address: Alem 896, Floor 6, Buenos Aires, Argentina
Reply | Threaded
Open this post in threaded view
|

Re: #numTemps/tempCountOf: is not working correctly

Levente Uzonyi
 


On Sat, 20 Oct 2018, Hernan Wilkinson wrote:

> It returns 1, but that method has 3 temps. The same happens with other methods like "(SmallInteger>>#printOn:base:length:padded:) numTemps", that return 9 but the method has 8 temps.

That method has one temporary variable which holds the indirection vector
containing the slots for the three variables the closure closes over.

"Any closed-over variable which does change after being closed over is put
in a heap-allocated "indirection vector" (a simple array, one element per
closed-over variable) and the indirection vector is copied into the
closure. All accesses to the variable are made through the indirection
vector." - http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/

Levente
Reply | Threaded
Open this post in threaded view
|

Re: #numTemps/tempCountOf: is not working correctly

Hernan Wilkinson-3
 
Thank you! now I understand :-)

On Sat, Oct 20, 2018 at 8:40 PM Levente Uzonyi <[hidden email]> wrote:
 


On Sat, 20 Oct 2018, Hernan Wilkinson wrote:

> It returns 1, but that method has 3 temps. The same happens with other methods like "(SmallInteger>>#printOn:base:length:padded:) numTemps", that return 9 but the method has 8 temps.

That method has one temporary variable which holds the indirection vector
containing the slots for the three variables the closure closes over.

"Any closed-over variable which does change after being closed over is put
in a heap-allocated "indirection vector" (a simple array, one element per
closed-over variable) and the indirection vector is copied into the
closure. All accesses to the variable are made through the indirection
vector." - http://www.mirandabanda.org/cogblog/2008/07/22/closures-part-ii-the-bytecodes/

Levente


--
Hernán Wilkinson
Agile Software Development, Teaching & Coaching
Phone: +54-011-4893-2057
Twitter: @HernanWilkinson
Address: Alem 896, Floor 6, Buenos Aires, Argentina