[squeak-dev] Reusable browsers was Re: About HyperCard

Juan Vuletich (mail lists) juanlists at jvuletich.org
Sat Mar 2 01:57:15 UTC 2013


Quoting Chris Muller <asqueaker at gmail.com>:

>> Try this:
>>
>>         self do: [:i | ] separatedBy: []
>
> Ha, ok, well, score +1 again for formatting code with more spacing in
> it (total score:  3-1).  ;-)  I never noticed "block args" having the
> problem since I always use more spacing (and, I guess, the code in the
> system I've ever traced).
>
> So the real issue appears to be related to when a colon follows a
> non-whitespace character, as it does in your example and in
> keyword-selector symbol case:
>
>       self perform: #add: with: anObject
>
> I just saw Bobs msg did half the work finding the method..  Hmm..

This could be fixed with:

findSelector
	"Dan's code for hunting down selectors with keyword parts; while this  
doesn't give a true parse, in most cases it does what we want, in  
where it doesn't, we're none the worse for it."
	| sel possibleParens level n keywordPos foundFirstKeyword |
	sel _ self withBlanksTrimmed.
	(sel includes: $:) ifTrue: [
		sel _ sel copyReplaceAll: ':' with: ': '.	"for the style (aa max:bb)  
with no space"
		sel _ sel copyReplaceAll: '[:' with: '[ :'.    "for the style ([:a)  
with no space"
		possibleParens _ sel findTokens: Character separators.
		sel _ String streamContents: [ :s |
			level _ 0.
			foundFirstKeyword _ false.
			keywordPos _ false.
			possibleParens do: [ :token |
				foundFirstKeyword
					ifFalse: [ token last = $: ifTrue: [ foundFirstKeyword _  
keywordPos _ true ]]
					ifTrue: [ keywordPos _  keywordPos not ].
				(level = 0 and: [ keywordPos ])
					ifTrue: [s nextPutAll: token]
					ifFalse: [(n _ token occurrencesOf: $( ) > 0 ifTrue: [level _ level + n].
							(n _ token occurrencesOf: $[ ) > 0 ifTrue: [level _ level + n].
							(n _ token occurrencesOf: $] ) > 0 ifTrue: [level _ level - n].
							(n _ token occurrencesOf: $) ) > 0 ifTrue: [level _ level - n]]]]].

	sel isEmpty ifTrue: [^ nil].
	Symbol hasInterned: sel ifTrue: [ :aSymbol |
		^ aSymbol].
	^ nil

I did it in Cuis. For Squeak, add the #isOctetString line.

Cheers,
Juan Vuletich



More information about the Squeak-dev mailing list