Symbol>>#precedence is wrong about #_whatever and #_whatever:

26 views
Skip to first unread message

Richard Sargent

unread,
Apr 17, 2015, 1:37:31 PM4/17/15
to va-sma...@googlegroups.com
The #precedence method, used to identify the type of selector a Symbol is, incorrectly handles selectors beginning with an underscore.

A symbol is a binary selector if and only if every character meets the test defined in #abrIsSelectorCharacter (which suffers from being a misleading name).
A symbol is a unary selector if and only if every character meets the test [_a-zA-z][_a-zA-z0-9]*.
A symbol is a keyword selector if and only if every character meets the test [_a-zA-z][_a-zA-z0-9:]* and the last character is a colon.

John O'Keefe

unread,
Apr 17, 2015, 4:20:34 PM4/17/15
to va-sma...@googlegroups.com
Richard -

You are correct about the underscore. You will notice that the receiver of this method is assumed to be a valid Smalltalk selector, so it is sufficient to test only the first and last characters to determine unary, binary, keyword, or invalid. Case 57740 created.

John

Richard Sargent

unread,
Apr 17, 2015, 4:33:38 PM4/17/15
to VA Smalltalk
On Fri, Apr 17, 2015 at 1:20 PM, John O'Keefe <john_...@instantiations.com> wrote:
Richard -

You are correct about the underscore. You will notice that the receiver of this method is assumed to be a valid Smalltalk selector, so it is sufficient to test only the first and last characters to determine unary, binary, keyword, or invalid. Case 57740 created.

Thanks, John.
It would be nice if there were a correspondingly simple method (or methods) to determine whether a given Symbol was actually a valid selector. Especially so since these existing methods are in CLDT and don't prescribe how they must be used.
 

John

On Friday, April 17, 2015 at 1:37:31 PM UTC-4, Richard Sargent wrote:
The #precedence method, used to identify the type of selector a Symbol is, incorrectly handles selectors beginning with an underscore.

A symbol is a binary selector if and only if every character meets the test defined in #abrIsSelectorCharacter (which suffers from being a misleading name).
A symbol is a unary selector if and only if every character meets the test [_a-zA-z][_a-zA-z0-9]*.
A symbol is a keyword selector if and only if every character meets the test [_a-zA-z][_a-zA-z0-9:]* and the last character is a colon.

And I guess I should elaborate this last one with the condition "and there are no sequences of multiple colons".
 

--
You received this message because you are subscribed to a topic in the Google Groups "VA Smalltalk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/va-smalltalk/IirYjnWHOt4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to va-smalltalk...@googlegroups.com.
To post to this group, send email to va-sma...@googlegroups.com.
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages