message name with the spaces ?

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

message name with the spaces ?

Mark Pirogovsky-3
Hello all !

is it possible to create the message with the space imbedded in the
selector ?

something along the lines

field stream
        ^self fieldStream


the reason I want to do that is  --  to  be able to use the following
construct:

anObject perform:'field stream'asSymbol



--Mark

Reply | Threaded
Open this post in threaded view
|

AW: message name with the spaces ?

Georg Heeg
Mark,

Certainly you can do that, although there is no support for this in the
browser or in the compiler. I just tried it, it works.

Here comes the cookbook:

1. Define the method you desire with a regular name e.g. testSpace in your
class Test4Space.
2. Execute the following statement:
        Test4Space methodDictionary at: #'test space' put: (Test4Space
methodDictionary at: #testSpace)
3. Execute the following statement:
        Test4Space new perform: #'test space'
   Or
        Test4Space new perform: 'test space' asSymbol

It works.

Certainly you cannot fileout Test4Space class and expect to get the strange
method back, you cannot see the strange method in a browser, you cannot
publish the strange method, and you probably cannot parcel out the strange
method name. But you can certainly reconstruct the behaviour using the same
trick after loading.

But: Why do you need it?

Georg


-----Ursprüngliche Nachricht-----
Von: Mark Pirogovsky [mailto:[hidden email]]
Gesendet: Dienstag, 24. Januar 2006 20:49
An: [hidden email]
Betreff: message name with the spaces ?

Hello all !

is it possible to create the message with the space imbedded in the
selector ?

something along the lines

field stream
        ^self fieldStream


the reason I want to do that is  --  to  be able to use the following
construct:

anObject perform:'field stream'asSymbol



--Mark


Reply | Threaded
Open this post in threaded view
|

Re: message name with the spaces ?

Dennis smith-4
In reply to this post by Mark Pirogovsky-3
I just read Georg Heeg's response, and my response is still "no!"

So just create a method called
    myPerform: aString
          str := aString collect: [:c | c isLetter | c isDigit ifTrue:
[c] ifFalse: [$_].
          ^self perform: str asSymbol

Now make your method

    field_stream
          ...



Mark Pirogovsky wrote:

> Hello all !
>
> is it possible to create the message with the space imbedded in the
> selector ?
>
> something along the lines
>
> field stream
>     ^self fieldStream
>
>
> the reason I want to do that is  --  to  be able to use the following
> construct:
>
> anObject perform:'field stream'asSymbol
>
>
>
> --Mark
>

--
Dennis Smith                        [hidden email]
Cherniak Software Development Corporation       +1 905.771.7011
400-10 Commerce Valley Dr E                Fax: +1 905.771.6288
Thornhill, ON Canada L3T 7N7    http://www.CherniakSoftware.com