Hi All,<div><br></div><div> this quick hack (below) is perhaps wrong. Perhaps we should simply accept underscores in selectors period, and not query the preference. If so <br><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Scanner prefAllowUnderscoreSelectors ifFalse:</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>[self class isBytes</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable: Tokenish) > 0 ifTrue: [^ -1]]</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^ -1]]]].</div><div><br></div><div>should read</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Scanner prefAllowUnderscoreSelectors ifFalse:</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>[2 to: self size do: [:i | ((self at: i) tokenish or: [(self at: i) == $_]) ifFalse: [^ -1]]].</div></div><div><br></div><div>Instead perhaps tokenish should be redefined to allow underscores? I'd appreciate input from those that have thought about this area carefully (I have not).</div>
<div><br></div><div class="gmail_quote">On Thu, Sep 29, 2011 at 12:42 PM, <span dir="ltr"><<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Eliot Miranda uploaded a new version of Collections to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Collections-eem.460.mcz" target="_blank">http://source.squeak.org/trunk/Collections-eem.460.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-eem.460<br>
Author: eem<br>
Time: 29 September 2011, 12:42:36.39 pm<br>
UUID: 0b90a58f-9354-4927-91f0-3432359541fe<br>
Ancestors: Collections-ul.459<br>
<br>
Fix String>numArgs for prefAllowUnderscoreSelectors regime.<br>
<br>
=============== Diff against Collections-ul.459 ===============<br>
<br>
Item was changed:<br>
----- Method: String>>numArgs (in category 'accessing') -----<br>
numArgs<br>
"Answer either the number of arguments that the receiver would take if considered a selector. Answer -1 if it couldn't be a selector. Note that currently this will answer -1 for anything begining with an uppercase letter even though the system will accept such symbols as selectors. It is intended mostly for the assistance of spelling correction."<br>
<br>
| firstChar numColons excess start ix |<br>
self size = 0 ifTrue: [^ -1].<br>
firstChar := self at: 1.<br>
(firstChar isLetter or: [firstChar = $:]) ifTrue:<br>
["Fast reject if any chars are non-alphanumeric<br>
NOTE: fast only for Byte things - Broken for Wide"<br>
+ Scanner prefAllowUnderscoreSelectors ifFalse:<br>
+ [self class isBytes<br>
+ ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable: Tokenish) > 0 ifTrue: [^ -1]]<br>
+ ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^ -1]]]].<br>
- self class isBytes<br>
- ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable: Tokenish) > 0 ifTrue: [^ -1]]<br>
- ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^ -1]]].<br>
"Fast colon count"<br>
numColons := 0. start := 1.<br>
[(ix := self indexOf: $: startingAt: start) > 0]<br>
whileTrue:<br>
[numColons := numColons + 1.<br>
start := ix + 1].<br>
numColons = 0 ifTrue: [^ 0].<br>
firstChar = $:<br>
ifTrue: [excess := 2 "Has an initial keyword, as #:if:then:else:"]<br>
ifFalse: [excess := 0].<br>
self last = $:<br>
ifTrue: [^ numColons - excess]<br>
ifFalse: [^ numColons - excess - 1 "Has a final keywords as #nextPut::andCR"]].<br>
firstChar isSpecial ifTrue:<br>
[self size = 1 ifTrue: [^ 1].<br>
2 to: self size do: [:i | (self at: i) isSpecial ifFalse: [^ -1]].<br>
^ 1].<br>
^ -1.!<br>
<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div><br>
</div>