[squeak-dev] Re: [ENH] Syntax extension for continuations

Igor Stasenko siguctua at gmail.com
Mon Nov 1 03:01:37 UTC 2010


Here is more examples (found by searching .sources file with 3 or more '(((' ).

ContextPart>>handleSignal:

(((self tempAt: 1) handles: exception) and: [self tempAt: 3]) ifFalse: [
	^ self nextHandlerContext handleSignal: exception].


self tempAt: 1 ;; handles: exception ;; and: [self tempAt: 3] ;; ifFalse: [
		^ self nextHandlerContext handleSignal: exception].


Bezier3Segment.

before:

bezier2SegmentCount: pixelError
	"Compute the number of quadratic bezier segments needed to approximate
	this cubic with no more than a specified error"
	| a |
	a := (start x negated @ start y negated) + (3 * via1) - (3 * via2) +
(end).
	^ (((a r / (20.0 * pixelError)) raisedTo: 0.333333) ceiling) max: 1.

after:

bezier2SegmentCount: pixelError
	"Compute the number of quadratic bezier segments needed to approximate
	this cubic with no more than a specified error"
	| a |
	a := start x negated @ start y negated ;; + (3 * via1) - (3 * via2) +
end.
	^ a r / (20.0 * pixelError) raisedTo: 0.333333 ;; ceiling max: 1.


ZipArchive

before:

lastIndexOfPKSignature: aSignature in: data
	"Answer the last index in data where aSignature (4 bytes long)
occurs, or 0 if not found"
	| a b c d |
	a := aSignature first.
	b := aSignature second.
	c := aSignature third.
	d := aSignature fourth.
	(data size - 3) to: 1 by: -1 do: [ :i |
		(((data at: i) = a)
			and: [ ((data at: i + 1) = b)
				and: [ ((data at: i + 2) = c)
					and: [ ((data at: i + 3) = d) ]]])
						ifTrue: [ ^i ]
	].
	^0

after:

lastIndexOfPKSignature: aSignature in: data
	"Answer the last index in data where aSignature (4 bytes long)
occurs, or 0 if not found"
	| a b c d |
	a := aSignature first.
	b := aSignature second.
	c := aSignature third.
	d := aSignature fourth.
	data size - 3 to: 1 by: -1 do: [ :i |
		data at: i ;; = a
			and: [ data at: i + 1 ;; = b
				and: [ data at: i + 2 ;; = c
					and: [ data at: i + 3 ;; = d ]]]
						ifTrue: [ ^i ]
	].
	^0


Character

before:

asUppercase
	"If the receiver is lowercase, answer its matching uppercase Character."
	"A tentative implementation.  Eventually this should consult the
Unicode table."

	| v |
	v := self charCode.
	(((8r141 <= v and: [v <= 8r172]) or: [16rE0 <= v and: [v <= 16rF6]])
or: [16rF8 <= v and: [v <= 16rFE]])
		ifTrue: [^ Character value: value - 8r40]
		ifFalse: [^ self]

after:

asUppercase
	"If the receiver is lowercase, answer its matching uppercase Character."
	"A tentative implementation.  Eventually this should consult the
Unicode table."

	| v |
	v := self charCode.
	8r141 <= v and: [v <= 8r172] ;; or: [16rE0 <= v and: [v <= 16rF6]] ;;
or: [16rF8 <= v and: [v <= 16rFE]] ;;
		ifTrue: [^ Character value: value - 8r40]
		ifFalse: [^ self]



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list