logo       

Re: Re: translateFrom:to:table:: msg#00221

lang.smalltalk.squeak.beginners

Subject: Re: Re: translateFrom:to:table:

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@xxxxxxxxx> 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@xxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxxxxxx
http://lists.squeakfoundation.org/mailman/listinfo/beginners






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise