Underscores in method names

Ian Piumarta ian.piumarta at inria.fr
Thu Oct 17 12:36:23 UTC 2002


On Thu, 17 Oct 2002, Nevin Pratt wrote:
> Tim Rowledge wrote:
> >Nevin Pratt <nevin at smalltalkpro.com> is claimed by the authorities to have written:
> >
> >>I was wondering if anybody knew what the rationale for disallowing 
> >>underscores in method names for Squeak was.  For other dialects, this is 
> >>allowed.
> >>
> >Because the underscore is mapped to the assign arrow.

This is only a reason for not allowing them as the first character in a
selector.  (The Scanner would have to be made context sensitive which
AFAIK it currently isn't.)

Ian
-------------- next part --------------
'From Squeak3.2 of 15 January 2002 [latest update: #4881] on 17 October 2002 at 2:30:42 pm'!
"Change Set:		underscoreMadness
Date:			17 October 2002
Author:			Ian Piumarta

Makes the Scanner accept underscores in words or keywords (but not in the first position since that would require context sensitivity).  Use of this changeset has been officially condemned by the Independent Board of Syntactical Aesthetics for Squeak."!


!Scanner methodsFor: 'multi-character scans' stamp: 'ikp 10/17/2002 14:24'!
xLetter
	"Form a word or keyword."

	| type |
	buffer reset.
	[(type _ typeTable at: hereChar asciiValue) == #xLetter or: [type == #xDigit or: [type == #leftArrow]]]
		whileTrue:
			["open code step for speed"
			buffer nextPut: hereChar.
			hereChar _ aheadChar.
			source atEnd
				ifTrue: [aheadChar _ 30 asCharacter "doit"]
				ifFalse: [aheadChar _ source next]].
	(type == #colon or: [type == #xColon and: [aheadChar ~= $=]])
		ifTrue: 
			[buffer nextPut: self step.
			["Allow any number of embedded colons in literal symbols"
			(typeTable at: hereChar asciiValue) == #xColon]
				whileTrue: [buffer nextPut: self step].
			tokenType _ #keyword]
		ifFalse: 
			[tokenType _ #word].
	token _ buffer contents! !



More information about the Squeak-dev mailing list