Login  Register

Re: About a object life

Posted by Mariano Martinez Peck on Nov 05, 2012; 1:03pm
URL: https://forum.world.st/About-a-object-life-tp4653839p4653973.html




On Mon, Nov 5, 2012 at 1:28 PM, Bert Freudenberg <[hidden email]> wrote:
On 2012-11-03, at 22:45, Mariano Martinez Peck <[hidden email]> wrote:

> On Sat, Nov 3, 2012 at 3:26 PM, Edgar J. De Cleene <[hidden email]> wrote:
>> Folks:
>>
>> I wish know how old a object is.
>>
> The VM can know if an object is in the young or old area. You could modify the VM and make a primitive that answers this (#isYoung: anOop).

What's wrong with the existing primitiveIsYoung? ;)


Sorry, I though we only had #isYoung:  and I forgot we also had the primitiveIsYoung and even the image side message :)

 
SmalltalkImage current isYoung: true
==> false

SmalltalkImage current isYoung: Object new
==> true


Also, since our GC does not change the order of objects when compacting, you can tell if an object is older than another by enumerating all objects. The oldest ones are of course nil, false, and true (more than 30 years old now):



This is very interesting!!! 
Thanks Bert. 
 
(1 to: 20) inject: self someObject into: [:obj :i |
        Transcript show: i; space; show: (obj printString contractTo: 60); cr.
        obj nextObject]
==>
1 nil
2 false
3 true
4 #Processor->a ProcessorScheduler
5 #(#+ 1 #- 1 #< 1 #> 1 #<= 1 #... 1 #new 0 #new: 1 #x 0 #y 0)
6 {Character value: 0 . Charact...$ú . $û . $ü . $ý . $þ . $ÿ}
7 {CompiledMethod . nil . Array...nil . nil . nil . nil . nil}
8 #Transcript->a TranscriptStream ' '
9 #SourceFiles->an ExpandedSour...s/Work/Frank/frank.changes')
10 #Display->DisplayScreen(1920x1200x32)
11 #Sensor->an EventSensor
12 $'
13 $,
14 $-
15 $.
16 $0
17 $;
18 $=
19 $[
20 $_


- Bert -





--
Mariano
http://marianopeck.wordpress.com