valid characters for binary selector

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

valid characters for binary selector

Chris Muller-4
I was looking for every valid character allowed as part of a binary selector name.  Nothing in SelectorNode was obvious to me, but the AST diagram in my copy of Smalltalk-80, The Language and Implementation, says they are:

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

Is this still correct?


Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

Chris Muller-4
It also seems to indicate that - (minus) is only allowed all by itself, not with any of the others.

The others are limited to a maximum of two.

However, I was just able to save (compile) a method named -@+.   So is it okay / advisable to go beyond the original spec if it lets me?

On Sat, May 25, 2019 at 6:04 PM Chris Muller <[hidden email]> wrote:
I was looking for every valid character allowed as part of a binary selector name.  Nothing in SelectorNode was obvious to me, but the AST diagram in my copy of Smalltalk-80, The Language and Implementation, says they are:

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

Is this still correct?


Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

Jecel Assumpcao Jr
Chris Muller wrote on Sat, 25 May 2019 18:08:28 -0500
> I was looking for every valid character allowed as part of a binary selector
> name.  Nothing in SelectorNode was obvious to me, but the AST diagram in
> my copy of Smalltalk-80, The Language and Implementation, says they are:
>      - + / * ~ < > = @ % | & ? !
> Is this still correct?

In code this is defined in method Scanner class>initialize where
everything is a binary character by default, then tab lf ff cr space are
redefined as delimiters, then the digits are redefined, then the letters
and then "  #  $  '  :  (  )  .  ;  [  ]  {  }  ^  _ | each get their
own token type. This means characters from 128 to 255 are also valid in
binary selectors and even a bunch of control characters!

> It also seems to indicate that - (minus) is only allowed all by itself, not with
> any of the others.
> The others are limited to a maximum of two.
> However, I was just able to save (compile) a method named -@+.   So is it
> okay / advisable to go beyond the original spec if it lets me?

This is defined in Scanner>>xBinary

The two character limit is no longer there and the only restriction
relative to $- is that it can't be immediately followed by a digit (in
which case we can't tell if it is supposed to be the sign of the
following number or the last character of the binary selector).

I would avoid creating selectors that would not be valid in other
Smalltalks if I might want to port my code later on. In the ANSI
Smalltalk standard binary selectors can have any number of characters,
but these must only be ! % & * + , / < = > ? @ \ ~ | -

Binary selectors with the vertical bar are valid in ANSI but not in
Squeak (they can mess things up with the block syntax and so aren't a
good idea anyway).

-- Jecel

Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

Tobias Pape

> On 27.05.2019, at 21:52, Jecel Assumpcao Jr. <[hidden email]> wrote:
>
> Chris Muller wrote on Sat, 25 May 2019 18:08:28 -0500
>> I was looking for every valid character allowed as part of a binary selector
>> name.  Nothing in SelectorNode was obvious to me, but the AST diagram in
>>  my copy of Smalltalk-80, The Language and Implementation, says they are:
>>      - + / * ~ < > = @ % | & ? !
>> Is this still correct?
>
> In code this is defined in method Scanner class>initialize where
> everything is a binary character by default, then tab lf ff cr space are
> redefined as delimiters, then the digits are redefined, then the letters
> and then "  #  $  '  :  (  )  .  ;  [  ]  {  }  ^  _ | each get their
> own token type. This means characters from 128 to 255 are also valid in
> binary selectors and even a bunch of control characters!
>
>> It also seems to indicate that - (minus) is only allowed all by itself, not with
>> any of the others.
>> The others are limited to a maximum of two.
>> However, I was just able to save (compile) a method named -@+.   So is it
>> okay / advisable to go beyond the original spec if it lets me?
>
> This is defined in Scanner>>xBinary
>
> The two character limit is no longer there and the only restriction
> relative to $- is that it can't be immediately followed by a digit (in
> which case we can't tell if it is supposed to be the sign of the
> following number or the last character of the binary selector).
>
> I would avoid creating selectors that would not be valid in other
> Smalltalks if I might want to port my code later on. In the ANSI
> Smalltalk standard binary selectors can have any number of characters,
> but these must only be ! % & * + , / < = > ? @ \ ~ | -
>
> Binary selectors with the vertical bar are valid in ANSI but not in
> Squeak (they can mess things up with the block syntax and so aren't a
> good idea anyway).

Btw: × works just fine....

¯\_(ツ)_/¯

Best regards
        -Tobias

Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

marcel.taeumel
In reply to this post by Chris Muller-4
So is it okay / advisable to go beyond the original spec if it lets me?

I would prefer an interface that still looks like message sending in the first place. I suppose there are some cases where the parser (or compiler) let's you do something that might just be an oversight. I would consider "-@+" way too cryptic.

That's the path you would be walking on if you follow that: 

self ><>.
self »-(¯`·.·´¯)->.
self --------{---(@.


Not good. Just my two cents.

Best,
Marcel

Am 26.05.2019 01:09:14 schrieb Chris Muller <[hidden email]>:

It also seems to indicate that - (minus) is only allowed all by itself, not with any of the others.

The others are limited to a maximum of two.

However, I was just able to save (compile) a method named -@+.   So is it okay / advisable to go beyond the original spec if it lets me?

On Sat, May 25, 2019 at 6:04 PM Chris Muller <[hidden email]> wrote:
I was looking for every valid character allowed as part of a binary selector name.  Nothing in SelectorNode was obvious to me, but the AST diagram in my copy of Smalltalk-80, The Language and Implementation, says they are:

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

Is this still correct?


Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

Chris Muller-3
In reply to this post by Jecel Assumpcao Jr
Thanks Jecel, that's exactly what I needed to know.

On Mon, May 27, 2019 at 2:52 PM Jecel Assumpcao Jr. <[hidden email]> wrote:

>
> Chris Muller wrote on Sat, 25 May 2019 18:08:28 -0500
> > I was looking for every valid character allowed as part of a binary selector
> > name.  Nothing in SelectorNode was obvious to me, but the AST diagram in
> > my copy of Smalltalk-80, The Language and Implementation, says they are:
> >      - + / * ~ < > = @ % | & ? !
> > Is this still correct?
>
> In code this is defined in method Scanner class>initialize where
> everything is a binary character by default, then tab lf ff cr space are
> redefined as delimiters, then the digits are redefined, then the letters
> and then "  #  $  '  :  (  )  .  ;  [  ]  {  }  ^  _ | each get their
> own token type. This means characters from 128 to 255 are also valid in
> binary selectors and even a bunch of control characters!
>
> > It also seems to indicate that - (minus) is only allowed all by itself, not with
> > any of the others.
> > The others are limited to a maximum of two.
> > However, I was just able to save (compile) a method named -@+.   So is it
> > okay / advisable to go beyond the original spec if it lets me?
>
> This is defined in Scanner>>xBinary
>
> The two character limit is no longer there and the only restriction
> relative to $- is that it can't be immediately followed by a digit (in
> which case we can't tell if it is supposed to be the sign of the
> following number or the last character of the binary selector).
>
> I would avoid creating selectors that would not be valid in other
> Smalltalks if I might want to port my code later on. In the ANSI
> Smalltalk standard binary selectors can have any number of characters,
> but these must only be ! % & * + , / < = > ? @ \ ~ | -
>
> Binary selectors with the vertical bar are valid in ANSI but not in
> Squeak (they can mess things up with the block syntax and so aren't a
> good idea anyway).
>
> -- Jecel
>

Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

Chris Muller-3
In reply to this post by marcel.taeumel
> > So is it okay / advisable to go beyond the original spec if it lets me?
>
> I would prefer an interface that still looks like message sending in the first place. I suppose there are some cases where the parser (or compiler) let's you do something that might just be an oversight. I would consider "-@+" way too cryptic.

Yes, I wouldn't ever use it.  It was just a test to see if the
compiler would accept it.

> That's the path you would be walking on if you follow that:
>
> self ><>.
> self »-(¯`·.·´¯)->.
> self --------{---(@.

OMG, LOL!!!!!!

> https://1lineart.kulaone.com/#/ :-)

Wow.

>
> Not good. Just my two cents.

Yes, definitely not good.  I would never do it but my query is for how
to take foreign code as an input, and I must convert binary selectors
to an alphanumeric to conform to an underlying protocol, (while
avoiding colliding with any keyword selectors), and with a
reverse-conversion on the other end.  So I needed to know all the
possibilities to possibly expect for binary selectors, and even
wondered whether I should disallow some based on some of those
dimensions Jecel mentioned like standards.

Cheers,
  Chris

Reply | Threaded
Open this post in threaded view
|

Re: valid characters for binary selector

timrowledge


On 2019-05-29, at 7:54 PM, Chris Muller <[hidden email]> wrote:

So is it okay / advisable to go beyond the original spec if it lets me?

I would prefer an interface that still looks like message sending in the first place. I suppose there are some cases where the parser (or compiler) let's you do something that might just be an oversight. I would consider "-@+" way too cryptic.

Yes, I wouldn't ever use it.  It was just a test to see if the
compiler would accept it.

That's the path you would be walking on if you follow that:

self ><>.
self »-(¯`·.·´¯)->.
self --------{---(@.

Eeeek.

Of course, the burning question is whether unicode emoji char points are valid for unary/binary selectors? 
 foo 👈 42 🧛‍♂️ + myThing 🇬🇧 thatThing

ie foo := 42 vampire + myThing union thatThing 

🧐
Almost Smalltalk-72 ?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
C++ is history repeated as tragedy. Java is history repeated as farce.