from #foo:bar: to foo: arg1 bar: arg2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

from #foo:bar: to foo: arg1 bar: arg2

Stéphane Ducasse
Hi

does one of you get to know a method for doing that?

#foo:bar:

        ->  foo: arg1 bar: arg2

Stef

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: from #foo:bar: to foo: arg1 bar: arg2

Stéphane Ducasse
may be we should add it somewhere in symbol because this is handy when  
you want to generate methods on the fly.

signatureFromSelector: aSelector
        "self new signatureFromSelector: #foo:bar: "
        "self new signatureFromSelector: #foo"
        "self new signatureFromSelector: #foo:"
        | count |
        ^ String streamContents: [:str|
                count := 1.
                (ReadStream on: aSelector) do: [:each |
                                        each = $:
                                                ifTrue: [ str nextPut: each.
                                                                str nextPutAll: ' arg', count printString, ' '.
                                                                count := count + 1]
                                                ifFalse: [str nextPut: each]
                                                ]]
               
               


On Mar 1, 2009, at 7:18 PM, Stéphane Ducasse wrote:

> Hi
>
> does one of you get to know a method for doing that?
>
> #foo:bar:
>
> ->  foo: arg1 bar: arg2
>
> Stef
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: from #foo:bar: to foo: arg1 bar: arg2

Lukas Renggli
In reply to this post by Stéphane Ducasse
The refactoring browser has this:

genericPatternForSelector: aSymbol
        ^ String streamContents: [ :stream |
                aSymbol keywords keysAndValuesDo: [ :index :value |
                        stream space; nextPutAll: value.
                        aSymbol last = $:
                                ifTrue: [ stream space; nextPutAll: 'arg'; print: index ] ] ]

Lukas

On Sun, Mar 1, 2009 at 7:18 PM, Stéphane Ducasse
<[hidden email]> wrote:

> Hi
>
> does one of you get to know a method for doing that?
>
> #foo:bar:
>
>        ->  foo: arg1 bar: arg2
>
> Stef
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project