Greetings,
The main program I am working on now is called Books. If I evaluate Books allInstances => anOrderedCollection( aBook aBook aBook ) How do I set them all equal to nil like Books removeAllInstances. Books allInstances => anOrderedCollection(). Sincerely, Joseph. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Caution: lowskilled hobbyist anyway: Hi Joseph, Smalltalk garbageCollect does that automatically for you BUT it removes only objects that are not in connection with other objects. So you have to cut loose all connections from other objects to your Book instances. Maybe you have variables within a workspace pointing to some Book instances. Or a list object with references to all of your books. (How do you get to your books?) Even an inspector, explorer or debugger pointing to a Book instance keeps the garbagecollector from removing them. Hope that helps a little Rudolf -- Gesendet: Freitag, 23. September 2016 um 07:40 Uhr Von: "Joseph Alotta" <[hidden email]> An: [hidden email] Betreff: [Newbies] remove allInstances? Greetings, The main program I am working on now is called Books. If I evaluate Books allInstances => anOrderedCollection( aBook aBook aBook ) How do I set them all equal to nil like Books removeAllInstances. Books allInstances => anOrderedCollection(). Sincerely, Joseph. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Joseph: I agree with Rudolf. See also
http://forum.world.st/Deleting-an-instance-td3328590.html Have fun! David _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Joseph Alotta
Hi Joseph,
Try: Books allInstances do: [:b | b become: nil]. Lou On Fri, 23 Sep 2016 00:40:33 -0500, Joseph Alotta <[hidden email]> wrote: >Greetings, > >The main program I am working on now is called Books. > >If I evaluate > >Books allInstances => anOrderedCollection( aBook aBook aBook ) > >How do I set them all equal to nil like > >Books removeAllInstances. > >Books allInstances => anOrderedCollection(). > > >Sincerely, > >Joseph. Louis LaBrunda Keystone Software Corp. SkypeMe callto://PhotonDemon _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Nice. That causes Squeak 5.0 to unexpectedly quit.
But when I start again, there are no instances of Books. Sincerely, Joseph > On Sep 23, 2016, at 7:59 AM, Louis LaBrunda [via Smalltalk] <[hidden email]> wrote: > > Books allInstances do: [:b | b become: nil]. |
Woop woop, alarm alarm, error error. Sorry my alarm just went off. If Squeak quit after a become and you are seeing differences after not saving things, something is wrong. Be afraid, be very afraid. All the best, Ron Teitelbaum From: [hidden email] [mailto:[hidden email]] On Behalf Of Joseph Alotta Nice. That causes Squeak 5.0 to unexpectedly quit. View this message in context: Re: remove allInstances? _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
maybe they were garbage collected before the crash or on startup.
> On Sep 23, 2016, at 9:23 AM, Ron Teitelbaum [via Smalltalk] <[hidden email]> wrote: > > Woop woop, alarm alarm, error error. > > > > Sorry my alarm just went off. If Squeak quit after a become and you are seeing differences after not saving things, something is wrong. > > > > Be afraid, be very afraid. > > > > All the best, > > > > Ron Teitelbaum > > > > From: [hidden email] [mailto:[hidden email]] On Behalf Of Joseph Alotta > Sent: Friday, September 23, 2016 10:15 AM > To: [hidden email] > Subject: [Newbies] Re: remove allInstances? > > > > Nice. That causes Squeak 5.0 to unexpectedly quit. > > But when I start again, there are no instances of Books. > > Sincerely, > > Joseph > > > > > On Sep 23, 2016, at 7:59 AM, Louis LaBrunda [via Smalltalk] <[hidden email]> wrote: > > > > Books allInstances do: [:b | b become: nil]. > > > View this message in context: Re: remove allInstances? > Sent from the Squeak - Beginners mailing list archive at Nabble.com. > > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > > > If you reply to this email, your message will be added to the discussion below: > http://forum.world.st/remove-allInstances-tp4916693p4916819.html > To start a new topic under Squeak - Beginners, email [hidden email] > To unsubscribe from Squeak - Beginners, click here. > NAML |
In reply to this post by Louis LaBrunda
Hi,
On 23.09.2016, at 15:03, Louis LaBrunda <[hidden email]> wrote: > Hi Joseph, > > Try: > > Books allInstances do: [:b | b become: nil]. I would advise against that. Become is a sledgehammer and you're about to crush ants with it. What happens with 'a become: b' ? All occurrences of 'a' in the image are replaced by 'b' and (this is important) vice versa. So, all 'b's are replaces by 'a'. With your example, all occurrences of nil are replaced with an instance of Book, in the whole image. This is most probably _not_ what you want. These two versions work better: Books allInstances do: [:b | b becomeForward: nil]. Books allInstances do: [:b | b become: Object new]. The first avoids the 'vice versa' part of become: and is more safe, the second one does the switcharoo with a new object every time, wich is also more safe. Anyhow, I presume that your intent is to track down instances of Book wich you don't know where they are. Maybe they are actually unreferenced already, so Smalltalk garbageCollect can get already rid of them. If that does not help, you can try to track the references down by doing Books allInstances do: [:b | b chasePointers] which will open a PointerFinder for each of the rouge object so you can inspect where they get referenced. I hope this helps. Best regards -Tobias > > Lou > > On Fri, 23 Sep 2016 00:40:33 -0500, Joseph Alotta <[hidden email]> wrote: > >> Greetings, >> >> The main program I am working on now is called Books. >> >> If I evaluate >> >> Books allInstances => anOrderedCollection( aBook aBook aBook ) >> >> How do I set them all equal to nil like >> >> Books removeAllInstances. >> >> Books allInstances => anOrderedCollection(). >> >> >> Sincerely, >> >> Joseph. > -- > Louis LaBrunda > Keystone Software Corp. > SkypeMe callto://PhotonDemon > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi,
Tobias is right. I'm use to the VA Smalltalk one way #become: and forgot about Squeaks two way #become:, sorry about that. Lou On Fri, 23 Sep 2016 19:47:31 +0200, Tobias Pape <[hidden email]> wrote: >Hi, > >On 23.09.2016, at 15:03, Louis LaBrunda <[hidden email]> wrote: > >> Hi Joseph, >> >> Try: >> >> Books allInstances do: [:b | b become: nil]. > >I would advise against that. Become is a sledgehammer and you're about to crush ants with it. > >What happens with 'a become: b' ? All occurrences of 'a' in the image are replaced by 'b' and (this is important) vice versa. >So, all 'b's are replaces by 'a'. > >With your example, all occurrences of nil are replaced with an instance of Book, in the whole image. This is most probably _not_ what you want. > >These two versions work better: > >Books allInstances do: [:b | b becomeForward: nil]. >Books allInstances do: [:b | b become: Object new]. > >The first avoids the 'vice versa' part of become: and is more safe, the second one >does the switcharoo with a new object every time, wich is also more safe. > >Anyhow, I presume that your intent is to track down instances of Book wich you don't know where they are. > >Maybe they are actually unreferenced already, so > Smalltalk garbageCollect >can get already rid of them. > >If that does not help, you can try to track the references down by doing > > Books allInstances do: [:b | b chasePointers] > >which will open a PointerFinder for each of the rouge object so you can inspect where they get referenced. > >I hope this helps. > >Best regards > -Tobias > > >> >> Lou >> >> On Fri, 23 Sep 2016 00:40:33 -0500, Joseph Alotta <[hidden email]> wrote: >> >>> Greetings, >>> >>> The main program I am working on now is called Books. >>> >>> If I evaluate >>> >>> Books allInstances => anOrderedCollection( aBook aBook aBook ) >>> >>> How do I set them all equal to nil like >>> >>> Books removeAllInstances. >>> >>> Books allInstances => anOrderedCollection(). >>> >>> >>> Sincerely, >>> >>> Joseph. >> -- >> Louis LaBrunda >> Keystone Software Corp. >> SkypeMe callto://PhotonDemon >> >> _______________________________________________ >> Beginners mailing list >> [hidden email] >> http://lists.squeakfoundation.org/mailman/listinfo/beginners Louis LaBrunda Keystone Software Corp. SkypeMe callto://PhotonDemon _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |