[squeak-dev] The Trunk: Collections-eem.460.mcz

Bert Freudenberg bert at freudenbergs.de
Tue Oct 4 14:53:41 UTC 2011


On 04.10.2011, at 16:51, Levente Uzonyi wrote:

> On Thu, 29 Sep 2011, Eliot Miranda wrote:
> 
>> Hi All,
>> 
>> this quick hack (below) is perhaps wrong.  Perhaps we should simply
>> accept underscores in selectors period, and not query the preference.  If
>> so
>> 
>> Scanner prefAllowUnderscoreSelectors ifFalse:
>> [self class isBytes
>> ifTrue: [(self findSubstring: '~' in: self startingAt: 1 matchTable:
>> Tokenish) > 0 ifTrue: [^ -1]]
>> ifFalse: [2 to: self size do: [:i | (self at: i) tokenish ifFalse: [^
>> -1]]]].
>> 
>> should read
>> 
>> Scanner prefAllowUnderscoreSelectors ifFalse:
>> [2 to: self size do: [:i | ((self at: i) tokenish or: [(self at: i) == $_])
>> ifFalse: [^ -1]]].
>> 
>> 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).
> 
> I tried to resolve the issue of broken underscores in selectors support in the past, but it's not as easy as it seems to be at first sight. The biggest problem is the per class option for them. The current implmenetation is just scratching the surface, if you try to use it, you'll find that it's broken.
> 
> What are the problems:
> - only instance side methods can use selectors and class names with underscores in them
> - lack of support in the kernel (e.g. String >> #numArgs, Parser >> #parseSelector:, Parser >> #parseParameterNames, their senders, etc)
> - the tools lack support for them too, so even if you succeed writing such code, you can't load your code into another image. This problem is kinda impossible to solve in the current model if you have a class with an underscore in it's name.
> 
> So IMHO we should just drop the support for the per class option for underscores in selectors, keep the global preference and maybe enable it by default in the long term*. Not because we're about to use such selectors/class names in the core image, but to ease loading of external code.

+1

- Bert -

> Back to the original question, I changed #tokenish to return true for $_ when I tried to solve this problem.
> 
> 
> Levente
> 
> * For those who are worried about losing _ as an assignment operator: this preference is compatible with underscore assignments as long as you separate the operator from the variable and the operand with whitespaces. You can also change the value of the preference in your image if you need support of old-style code.




More information about the Squeak-dev mailing list