Re: [Newbies] remembering variables
Hello Peter, phm Can I get the debugger to show a tree of message sends, that I can browse? phm Something like that? I should have a ready made reply for this: Cris Muller, author of Magma created the TracingMessagesBrowser. This shows senders and implementors in an indented List. What you have to know is you can drag over messages in the indented list to select many and with shift right click (on windows) you get remove from this browser. You need this when you implement a message with a name that everybody loves and your implementors shows you a hundred implementors. Search the archives of Squeak dev and most important, get it from Squeak map. You'll like it. An algorithm encompasses 10 classes and you can work on it in *one* window. -- Cheers, Herbert ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] Explorer and MessageTally [was: remembering variables]
On Tue, 03 Jun 2008 05:57:48 +0200, peter h meadows wrote: Ah. Well, more often than not the variables in my code stay as one 'type' of thing. And I thought that generally they would otherwise things would get really confusing!? For this part of your question use Squeak's explorer. Try (World explore) to get an idea what it is about, for example expand the submorph branches that you see there. Sometimes when I try to understand how a program is working I get lost in the debugger. What I'd like is a kind of overview of what's going on. For this part of your question try (MessageTally spyOn: [Object compileAll]). Something I can browse and focus in on the parts that seem interesting. For MessageTally the parts of a computation which really do something are interesting. In theory I can do this with the system browser but it doesn't tell me how everything fits together. I want to see an overview of how all the parts fit together.. Who uses what.. Which bits are connected.. The order in which things are done, etc. MessageTally tells you how the parts of your computation fit together, who's using what, and the order in which things are done. Can I get the debugger to show a tree of message sends, that I can browse? Something like that? Yes, MessageTally does that for you: a tree of message sends. From the Spy results, you can select a class and browse it for more details, or a method and browse its senders or implementors for more details. Any ideas? thx. peter == peter h meadows [EMAIL PROTECTED] writes: peter Oh. I'm still very new to smalltalk. It seemed like it would help me to peter understand what's going on. I wanted it to remember everything. E.g if peter the thing is an array it will tell me what has been stored in it. Also, peter wouldn't it help with code completion? If it knows what type of object peter it was in the past it can guess which messages I want to send to peter it. That would be useful. But the problem is that a given type in the past is not any indication of a type in the future. You're not thinking smalltalk yet. Stop worrying about types. :) Oh, and they aren't types. They're instances of classes. If you want to see what's going on, learn to single step in the debugger. It's quite informative. ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] Explorer and MessageTally [was: remembering variables]
Hello Klaus, KDW Yes, MessageTally does that for you: a tree of message sends. From the Spy KDW results, you can select a class and browse it for more details, or a KDW method and browse its senders or implementors for more details. interesting idea to use it this way! But MessageTally IMHO only shows what it finds on the stack when it peeks. So it can miss some methods running seldom and quick. So you can do MessageTallytallySends: [your tallied block] which uses the simulator (sloow!!) but gets you everything. And to be real useful with long class names and deeply nested sends one might have to patch some of the class side methods of MessageTally in the defaults category. After looking I see it has become better with 3.9 so the latter applies only for 3.8 and older. -- Cheers, Herbert ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] Creating a SUnit Test for A Morphic Object
Hello All, I'm new to the list here, and I have a question on creating SUnit tests for Morphs. In my latest bi-annual Squeak Peek, something clicked that hadn't in the past 3 years of periodically checking into Squeak: It started to make sense (I usually give up in frustration after a week or so, but the, Squeak by Example book has really helped this time. Kudos to the writers). So, I started digging around in the Morphic classes, and I stumbled across, what appeared to be, a bug in LedDigitMorph. I played around with it until I felt satisfied that it was indeed a bug, and then submitted a report to bugs.squeak.org. The powers that be agreed that this looked like a bug, and asked me to do a little more footwork on it (I had submitted my fix with the report). However, I'm not quite sure how to accomplish what was requested. Here's the bug (mantis ID: 0007067), and a test case: LedDigitMorph does not change its state after receiving a digit: message. You have to click on the morph before it changes. The test case is: myDigit := LedDigitMorph new openInWorld. myDigit digit: 2. The morph will not show the number 2 until you click on it. I solved this bug in my image by changing the digit: message to this: digit: anInteger digit _ anInteger \\ 10. make sure it stays between 0 and 9 self changed. The response I got back asked me to create a SUnit test for this issue (One that fails before the patch and passes afterwards). Unfortunately, I'm not sure how to do this (though I'd be happy to continue to work on it). Can someone give me some guidance on how to go about creating SUnit test cases for this Morphic object? Thanks, Jason ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] Creating a SUnit Test for A Morphic Object
Quoting Jason Burke [EMAIL PROTECTED]: Hello All, I'm new to the list here, and I have a question on creating SUnit tests for Morphs. In my latest bi-annual Squeak Peek, something clicked that hadn't in the past 3 years of periodically checking into Squeak: It started to make sense (I usually give up in frustration after a week or so, but the, Squeak by Example book has really helped this time. Kudos to the writers). So, I started digging around in the Morphic classes, and I stumbled across, what appeared to be, a bug in LedDigitMorph. I played around with it until I felt satisfied that it was indeed a bug, and then submitted a report to bugs.squeak.org. The powers that be agreed that this looked like a bug, and asked me to do a little more footwork on it (I had submitted my fix with the report). However, I'm not quite sure how to accomplish what was requested. Here's the bug (mantis ID: 0007067), and a test case: LedDigitMorph does not change its state after receiving a digit: message. You have to click on the morph before it changes. The test case is: myDigit := LedDigitMorph new openInWorld. myDigit digit: 2. The morph will not show the number 2 until you click on it. I solved this bug in my image by changing the digit: message to this: digit: anInteger digit _ anInteger \\ 10. make sure it stays between 0 and 9 self changed. The response I got back asked me to create a SUnit test for this issue (One that fails before the patch and passes afterwards). Unfortunately, I'm not sure how to do this (though I'd be happy to continue to work on it). Can someone give me some guidance on how to go about creating SUnit test cases for this Morphic object? Thanks, Jason Hi Jason, I'm a newbie too, but thought I'd have a go at this. Looking at the changed method, it passes up through its owner morphs the rectangle that needs redrawing, which are then checked by the WorldState. So you can test that the world has a redraw needed: DigitTest testDigit | myDigit worldState | worldState := WorldState allInstances first. myDigit := LedDigitMorph new openInWorld. worldState doOneSubCycleFor: World world. clear out any redraws needed myDigit digit: 2. self should: [worldState checkIfUpdateNeeded]. This works. It will need someone more experienced than me to judge its (in)elegance, or whether it risks doing anything nasty in particular cases. Cheers,...Stan ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] Proper object removal
Hello, After much help already, I think I need some training in proper object removal. When my application creates an object and stores it in an OrderedCollection, and than wants to delete it, I am trying to do so quite explicitly with something like: DataManagerdeleteSelectedAbstractors self selected do: [:each | self abstractors remove: each. each := nil. ] which removes the object from my application (it's collection), and yet when I look for my object in the system with DataAbstractor allInstances. I still see the object I removed, even with an explicit Smalltalk garbageCollect or garbageCollectMost. Anything I create just seems to hang around forever. Any help understanding what I need to do to make sure my objects really go away when I am done with them would be greatly appreciated! Rob ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] Proper object removal
Hello Rob, RR After much help already, I think I need some training in proper object removal. RR DataAbstractor allInstances. if you inspect this you get an inspector on an Array. To the left select any entry with a left click (on Windows) and select objects pointing to this value. You get another inspector with an array of the objects pointing to the object you can't delete. Again inspecting one of these objects you can see how it points to your original object. This might give you a clue. And manually deleting these references (setting them to nil in the inspector) will eventually free your original object for garbage collection. If some of the objects you find are WeakArray or such you are in the (to me) murky area of finalization and weak references. Squeak dev would be the place to ask. You don't state the size of your problem. Is it three or is it thousands of instances hanging around?. I once tried the pointer finder tool but wasn't satisfied with it. And the swiki has a page on cleaning up junk. RR I still see the object I removed, even with an explicit RR Smalltalk garbageCollect or garbageCollectMost. RR Anything I create seems to hang around forever. Sometimes saving and reloading an image does a more thorough job than garbageCollect. Maybe because of the above mentioned weak references. -- Cheers, Herbert ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners