[Pkg] The Trunk: Compiler-nice.457.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Apr 16 20:19:40 UTC 2021


Nicolas Cellier uploaded a new version of Compiler to project The Trunk:
http://source.squeak.org/trunk/Compiler-nice.457.mcz

==================== Summary ====================

Name: Compiler-nice.457
Author: nice
Time: 16 April 2021, 10:19:30.223501 pm
UUID: e2ce8f47-9ed2-0d46-aca1-1dd90ebed4b4
Ancestors: Compiler-nice.456

Rename resume: source -> retryWithNewSource: source.

The purpose of such exception handling is indeed to retry the compilation with new source.

The purpose of resume: anObject is to return anObject to the context that sent signal, that's a slightly different semantic.

It happens that if we resume after setting newSource, the signaller (Parser>>notify:at:) will effectively then tryNewSourceIfAvailable.
So effectively, resuming will end up in retrying (if there is a handler of ReparseAfterSourceEditing up the sender stack, but the Parser normally puts one).

But, even if this is HOW we implement the #retryWithNewSource:,
this is not WHAT we wish to ask to the SyntaxErrorNotification.
in other words, we shouldn't let the implementation leak in the semantics, otherwise we put the burden of understanding the implementation on the shoulders of programmers, when they could just have trusted the semantics of pseudo natural language offered by keywords.

While at it, remove the accessors of newSource.
They are not used and may be considered private.
This will reduce the unecessary polymorphism.

=============== Diff against Compiler-nice.456 ===============

Item was removed:
- ----- Method: SyntaxErrorNotification>>newSource (in category 'accessing') -----
- newSource
- 	^newSource!

Item was removed:
- ----- Method: SyntaxErrorNotification>>newSource: (in category 'accessing') -----
- newSource: aTextOrString
- 	newSource := aTextOrString!

Item was removed:
- ----- Method: SyntaxErrorNotification>>resume: (in category 'accessing') -----
- resume: source
- 
- 	self reparse: source notifying: nil ifFail: nil.
- 	^ super resume: self defaultResumeValue!

Item was added:
+ ----- Method: SyntaxErrorNotification>>retryWithNewSource: (in category 'handling') -----
+ retryWithNewSource: source
+ 	"Retry the compilation with new source code.
+ 	Assume
+ 	- that the signallerContext will tryNewSourceIfAvailable
+ 	- the presence of a handler of ReparseAfterSourceEditing on the sender stack"
+ 	
+ 	newSource := source.
+ 	^ self resume!



More information about the Packages mailing list