writing binary selectors

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

writing binary selectors

Günther Schmidt
Hi,

I had wanted to ammend a '.. anInteger' as a binary selector to the
Integer class just for the sake of it. (Propably removing it afterwards).

But I don't seem to be able to add (new) binary selectors to the class,
how come, or rather how would I have to do this?.

Günther


Reply | Threaded
Open this post in threaded view
|

Re: writing binary selectors

Ian Bartholomew-19
Günther,

> But I don't seem to be able to add (new) binary selectors to the class,
> how come, or rather how would I have to do this?.

I think it's just that the Dolphin parser is not expecting some unusual
sequences of characters, ones that would not normally appear.  You can add
binary selectors to Integer though, you just have to be a bit careful what
characters you use..  For example, #?, #@@, #%% and #?? all work for me.

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: writing binary selectors

Chris Uppal-3
In reply to this post by Günther Schmidt
Günther Schmidt wrote:

> I had wanted to ammend a '.. anInteger' as a binary selector to the
> Integer class just for the sake of it. (Propably removing it afterwards).

I'm afraid you are out of luck.  You can't use '.' in a binary selector.

(Which is one of the more irritatingly short-sighted design errors in
Smalltalk, IMO.)

As far as I know, the characters that Dolphin will let you use in a binary
selector are:

    ! ? % & | * + - ~ , / \ < = > @

(Dolphin also used to allow just a single : as a binary selector, but I think
that was a bug, and it may be fixed by now.)

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: writing binary selectors

Ian Bartholomew-19
In reply to this post by Ian Bartholomew-19
I writted

> For example, #?, #@@, #%% and #?? all work for me.

Just to avoid _any_ confusion, in the above # just indicates a symbol and ,
a separator.  An example method definition would therefore be ...

@@ anInteger
    ^self + anInteger


Sorry

--
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.