[squeak-dev] Re: Newbie Question: How does this work?
Joseph J Alotta
joseph.alotta at gmail.com
Wed Oct 10 16:07:59 UTC 2012
I know I can make changes directly to String and add a method. But I was wondering if I can
add a method to String and still keep the code in my Package. (I've made my own package/category called JJA
that contains all the object that pertain to my program.)
So is there a way to create a method in my own category for a class in another category?
> Message: 4
> Date: Tue, 9 Oct 2012 16:16:59 +0100
> From: Frank Shearar <frank.shearar at gmail.com>
> Subject: Re: [squeak-dev] Re: Newbie Question: How does this work?
> To: The general-purpose Squeak developers list
> <squeak-dev at lists.squeakfoundation.org>
> <CAJbhyRH3WgsMDdYWMvnkdBF770kV=nqOOyxz1ysYrk=w4u_Ygg at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> On 9 October 2012 16:08, Joseph J Alotta <joseph.alotta at gmail.com> wrote:
>> Thanks for you help.
>> I see that String has a #printf and the protocol is *printf, and when the printf: method executes it looks everywhere for the FormatString class which is added to the end by the Printf package.
>> So the question is how did the *printf protocols get added to String? It is not some magic by Monticello, because I did not use
>> Monticello, I just filein-ed the code.
>> So where in the code does it install the *printf methods to String?
> The original code (in what's called "chunk format") was incomplete. If
> it had been complete (like the Printf Chris Cunnington's mentioned)
> you'd have seen something like this:
> !String methodsFor: '*printf'!
> printf: arguments
> ^ self asFormatString printf: arguments! !
> In Monticello these chunks are instead represented by MCDefinition subclasses.
More information about the Squeak-dev