[Newbies] Re: Questions about primitives - how to avoid one ?
Hi C'edrick, on Mon, 18 Feb 2008 01:10:41 +0100, you wrote: David T. Lewis wrote: If you comment out the primitive like this is should definitely work: If I comment out the primitive, in Float= ... and put a self halt after, the halt point has no effect. This is correct, both your observation and the corresponding behavior of Squeak's VM. There are some message selectors whose method is only looked up if receiver/args don't match, for performance reason. To this belongs #= (bytecode #182) which is first tried for SmallInteger receiver/args, then if that fails tried for Float receiver/args, and if that also fails then routine #bytecodePrimEqual in Squeak's VM performs a normal send (which would then find the primitive number and/or the Smalltalk code if the primitive where absent or failed). Looks complicated but works *fast* (only less failure is more speed :) For what you want to do I'd suggest you duplicate method Float#= as Float#~=~ (just add the two ~ in Float's #= selector and alt-s) and then you can do 1.234 ~=~ 1.234 and the changes you do to your #~=~ method then do what you want (it's Smalltalk land :) HTH. /Klaus ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] How to empty a collection?
On Feb 18, 2008, at 20:41 , itsme213 wrote: I want to clear its contents (size goes back to zero), and can't seem to find something like #clear or #empty. Cannot use a new collection as there are shared references to it. myCollection removeAllSuchThat: [:each | true] - Bert - ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] Loading Rome SVG package
I can load the following packages out of the squeaksource repository: Rome-Balloon Rome-Base Rome-PluginCanvas Rome-SVG Rome-Strike Rome-Tests Rome-Reference Rome-BalloonCanvas The rest give me errors about lacking other classes, which I reproduce below. Are the packages that load enough to be useful, or am I going to be stuffed when playing around with Rome? If so, where should I get the dependencies? Also, there's a lack of class comments. Is there documentation elsewhere? Is Rome even ready to be used at all? Rome-Demo also gives me a syntax error: fontFor: aCanvas family: aFamily style: aStyle has a full stop after the comment. After fixing this it gives me an error because RomeFreetypeCanvas is not recognised. Thanks all! Rome-Tweak depends on: This package depends on the following classes: CMatrixTransform CBitmapFill CTransformCanvas CDisplayTransform CCostumeFill CGraphicsFill CNoFill CIdentityTransform CProjectBuilder CSolidFill CGradientFill COffsetTransform Rome-FontManager: This package depends on the following classes: FreetypeFontFace FreetypeFont Rome-Plugin: This package depends on the following classes: SmartSyntaxInterpreterPlugin CCodeGenerator TSendNode ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] How to empty a collection?
Isn't Cedrick's aida solution going to be significantly faster? this is not mine :) butI'd interested to see if it's a good use of #become:... Does it keep references ? is it safe ? Thanks ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] How to empty a collection?
Isn't Cedrick's aida solution going to be significantly faster? On Feb 19, 2008 1:02 AM, Ron Teitelbaum [EMAIL PROTECTED] wrote: Hi Sophie, aCollection copy do: [:anElement | aCollection remove: anElement ]. Why copy? If you start removing items from the collection, increasing the index will cause you to skip elements. Ron -Original Message- From: itsme213 I want to clear its contents (size goes back to zero), and can't seem to find something like #clear or #empty. Cannot use a new collection as there are shared references to it. Thanks - Sophie ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] How to empty a collection?
My understanding as well is that this is the purpose of #become:, but also that it is not very efficient in some versions of Smalltalk. If you are using an OrderedCollection, this is probably a reasonably efficient method as it doesn't need to search through the whole list every time it removes an element: removeAll [self notEmpty] whileTrue: [self removeLast] Brian. On Feb 18, 2008 6:42 PM, Marcin Tustin [EMAIL PROTECTED] wrote: My own testing suggests that references to the object remain in place. I would guess that that is the whole point of become. On Feb 19, 2008 1:38 AM, cdrick [EMAIL PROTECTED] wrote: Isn't Cedrick's aida solution going to be significantly faster? this is not mine :) butI'd interested to see if it's a good use of #become:... Does it keep references ? is it safe ? Thanks ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
RE: [Newbies] How to empty a collection?
Hi Marcin, I'm not a fan of using #become. I will use it for very specific behavior when I need to retain pointers to an object. For example for implementing a proxy. In that case become is a very useful tool. I think that #become is overkill for this situation, but I won't argue that it doesn't work. In most cases you have a well encapsulated collection. That collection is not referenced outside the object so you can just reinitialize your collection without #become. If it is complicated enough to worry about pointers I wouldn't use #become. Someone will get lost and miss your #become hidden inside #removeAll: . I'm not saying this will cause problems but I think I would rather work with the collection directly instead of using the #become. Also if you are working on a collection that is large enough to worry about performance then you are probably missing a database that would significantly improve your performance. Ron Teitelbaum From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marcin Tustin Sent: Monday, February 18, 2008 8:43 PM To: A friendly place to get answers to even the most basic questions aboutSqueak. Subject: Re: [Newbies] How to empty a collection? My own testing suggests that references to the object remain in place. I would guess that that is the whole point of become. On Feb 19, 2008 1:38 AM, cdrick [EMAIL PROTECTED] wrote: Isn't Cedrick's aida solution going to be significantly faster? this is not mine :) butI'd interested to see if it's a good use of #become:... Does it keep references ? is it safe ? Thanks ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] 1-way #become: ?
#become: apparently (effectively) swaps object ids. Is there anything like x oneWayBecome: y that would pass this test: testOneWayBecome: x to: y | a b | a := x. b := y. x oneWayBecome: y. self assert: [x == y]. self assert: [a == y]. self assert: [b == y]. (Not related to my earlier collection empty question) Thanks - Sophie ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Re: [Newbies] 1-way #become: ?
See becomeForward: Gulik. On Feb 19, 2008 4:59 PM, itsme213 [EMAIL PROTECTED] wrote: #become: apparently (effectively) swaps object ids. Is there anything like x oneWayBecome: y that would pass this test: testOneWayBecome: x to: y | a b | a := x. b := y. x oneWayBecome: y. self assert: [x == y]. self assert: [a == y]. self assert: [b == y]. (Not related to my earlier collection empty question) Thanks - Sophie ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners -- http://people.squeakfoundation.org/person/mikevdg http://gulik.pbwiki.com/ ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
[Newbies] Re: How to empty a collection?
On Tue, 19 Feb 2008 02:35:34 +0100, Marcin Tustin wrote: Isn't Cedrick's aida solution going to be significantly faster? No, solutions based on #become: are the slowest possible. The VM has to sweep the whole memory, for all variables in the system, to find all references during #become:, like this | oop | oop := self someObject. [check+replace reference in variables of oop, then oop := oop nextObject. oop = 0 ] whileFalse. Now think that you (and every other user of your software ;-) have an .image with 2-4gigs every time you use #become: ... If you want something faster, look at Bert's myCollection removeAllSuchThat: [:each | true] and try to make it faster but keep still it correct (old elements must be nil'ed). /Klaus On Feb 19, 2008 1:02 AM, Ron Teitelbaum [EMAIL PROTECTED] wrote: Hi Sophie, aCollection copy do: [:anElement | aCollection remove: anElement ]. Why copy? If you start removing items from the collection, increasing the index will cause you to skip elements. Ron -Original Message- From: itsme213 I want to clear its contents (size goes back to zero), and can't seem to find something like #clear or #empty. Cannot use a new collection as there are shared references to it. Thanks - Sophie ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners