[Newbies] Re: Re: translateFrom:to:table:

Klaus D. Witzel klaus.witzel at cobss.com
Sun Jul 30 01:51:35 UTC 2006


If some method is not just a thing hanging around waiting for nothing (no  
senders, for example), you always will find its full implementation+use -  
that's the nature of the Smalltalk/Squeak system.

senders of #translateFrom:to:table:
=>String>>#translateWith:

senders of #translateWith: (nice examples for what the table argument is  
about)
=>String>>#translateToLowercase
=>String>>#translateToUppercase

implementors of #translateFrom:to:table:
=>ByteString class>>#translateFrom:to:table:
=>ByteSymbol class>>#translateFrom:to:table:
=>String class>>#translateFrom:to:table:

The String implementation tell exactly what argument is used for what,  
same with the primitive fallback code of the ByteString implementation.

Hope that helps.

/Klaus

On Sun, 30 Jul 2006 00:45:43 +0200, Thomas Keller <thokeller at gmail.com>  
wrote:

> That works for lots of methods. But for some methods there are no decent
> comments or examples. This is what I get from "Senders of
> translateFrom:to:table:"
>  translateWith: table
>     "translate the characters in the string by the given table, in place"
>     ^ self translateFrom: 1 to: self size table: table
>
> I don't find see anything called "references".
> I cannot find a single example of what a table arguments should look  
> like.
>
> Here's a simple example of what I want to do:
>
> myString := 'ACGTACGT'.
> myFixedString := myString translateFrom: 1 to; (myString size) table:  
> table.
>
> Where table would be something like a hash: A => 5, G => 6, C => 7, T =>  
> 8.
>
> in Perl, I would write: perl -pe 'tr/AGCT/5678/' <return> on the command
> line and then paste in the string and perl would return the translated
> string.
>
> Thanks for your help.
> Tom Keller
>
> On 7/28/06, Klaus D. Witzel <klaus.witzel at cobss.com> wrote:
>>
>> On Fri, 28 Jul 2006 20:49:13 +0200, Mathieu wrote:
>>
>> > Hi thomas,
>> >
>> > You can find some sender of it by right click -> more.. -> senders of  
>> it
>>
>> And there is a way to avoid stinkin' right-click: in any text, select  
>> the
>> text of a selector (including its arguments) and do cmd-m and cmd-n :)  
>> For
>> example, in a browser with the class definition template (Object  
>> subclass:
>> #NameOfSubclass ...) do select from subclass: to category: and see what  
>> I
>> mean.
>>
>> > So you can understand how people use it.
>>
>> Yes, one of the best ways to come to use to Smalltalk/Squeak.
>>
>> /Klaus
>>
>> > Other wise find the references to it and you can read comment of the
>> > metod or even understand the implementation. (follow same method for
>> > 'sender of it' but chose 'references to it')
>> >
>> > Math
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>
>
>
>




More information about the Beginners mailing list