I wish know how old a object is. Any have code for this ? Thanks in advance Edgar |
Am 11/03/2012 03:26 PM, schrieb Edgar
J. De Cleene:
For existing objects, it's impossible to know how old they are. For new objects, you can store a creation timestamp. Since this is very dependent on your actual needs, there is probably no ready-to-use code, but the functionality is really simple (assuming you have an instance variable creationTime): initialize super initialize. creationTime := DateAndTime now. age ^DateAndTime now - creationTime Cheers, Hans-Martin |
On 11/3/12 4:24 PM, "Hans-Martin Mosner" <[hidden email]> wrote: > For existing objects, it's impossible to know how old they are. > For new objects, you can store a creation timestamp. Since this is very > dependent on your actual needs, there is probably no ready-to-use code, but > the functionality is really simple (assuming you have an instance variable > creationTime): > > initialize > super initialize. > creationTime := DateAndTime now. > > age > ^DateAndTime now - creationTime > > Cheers, > Hans-Martin Well, you confirm my guess. Very thanks Hans Edgar |
In reply to this post by Hans-Martin Mosner
LocaleTest>>testLocaleChanged is a test that checks to ensure that the value
of the #useFormsInPaintBox changes when the locale changes from 'en' to 'ja'. This preference does not currently exist in Squeak trunk, so I am assuming that it refers to something Etoys related that may be incomplete in Squeak trunk. If this is correct, then I am inclined to mark #testLocaleChanged as an expected failure, with a comment to explain the above. Can anyone shed further light on this? Dave |
On 3 November 2012 19:42, David T. Lewis <[hidden email]> wrote:
> LocaleTest>>testLocaleChanged is a test that checks to ensure that the value > of the #useFormsInPaintBox changes when the locale changes from 'en' to 'ja'. > This preference does not currently exist in Squeak trunk, so I am assuming that > it refers to something Etoys related that may be incomplete in Squeak trunk. > > If this is correct, then I am inclined to mark #testLocaleChanged as an expected > failure, with a comment to explain the above. > > Can anyone shed further light on this? I agree with your analysis (but didn't know where the preference came from). I think we can restore testLocaleChanged by choosing a preference that's set one way in 'en' and a different way in 'ja'. I got lost in a maze of twisty dictionaries, all alike, trying to find such a preference. I'd hoped the last time I mentioned this test that someone would be able to point out such a preference. frank > Dave > > |
In reply to this post by Edgar De Cleene
On Sat, Nov 3, 2012 at 3:26 PM, Edgar J. De Cleene <[hidden email]> wrote:
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). So, this is not HOW OLD, but at least if it is young or old ;)
Mariano http://marianopeck.wordpress.com |
On 11/3/12 7:45 PM, "Mariano Martinez Peck" <[hidden email]> wrote: 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). Is a good pointer, thinking if the garbage collector could be used Gracias Marianoooo Edgar |
In reply to this post by Mariano Martinez Peck
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? ;) 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): (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 - |
On 11/5/12 10:28 AM, "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? ;) > > 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): > > (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 - Bert: Very thanks for this Edgar |
In reply to this post by Bert Freudenberg
On Mon, Nov 5, 2012 at 1:28 PM, Bert Freudenberg <[hidden email]> wrote:
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 This is very interesting!!! Thanks Bert. (1 to: 20) inject: self someObject into: [:obj :i | Mariano http://marianopeck.wordpress.com |
This wisdom deserves to be stored somewhere under the heading “Age of Objects” ;-) Hans From: Mariano Martinez Peck [mailto:[hidden email]]
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: 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 :)
This is very interesting!!! Thanks Bert.
-- |
Free forum by Nabble | Edit this page |