[squeak-dev] valid characters for binary selector

Chris Muller asqueaker at gmail.com
Thu May 30 02:43:26 UTC 2019


Thanks Jecel, that's exactly what I needed to know.

On Mon, May 27, 2019 at 2:52 PM Jecel Assumpcao Jr. <jecel at merlintec.com> 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 - at +.   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
>


More information about the Squeak-dev mailing list