The Trunk: Morphic-mt.1608.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Morphic-mt.1608.mcz

commits-2
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1608.mcz

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

Name: Morphic-mt.1608
Author: mt
Time: 13 December 2019, 10:02:28.682784 am
UUID: aefd108e-0a66-0041-a417-669c5b08df12
Ancestors: Morphic-mt.1607

Fixes a small glitch that I introduced in the last commit.

=============== Diff against Morphic-mt.1607 ===============

Item was changed:
  ----- Method: TextEditor>>evaluateSelectionAndDo: (in category 'do-its') -----
  evaluateSelectionAndDo: aBlock
  "Treat the current selection as an expression; evaluate it and invoke aBlock with the result."
 
  | result rcvr ctxt selectionInterval |
  self lineSelectAndEmptyCheck: [^ nil].
 
  (model respondsTo: #evaluateExpression:) ifTrue: [
  ^ aBlock value: (model perform: #evaluateExpression: with: self selection)].
 
  (model respondsTo: #doItReceiver)
  ifTrue: [ rcvr := model doItReceiver.
  ctxt := model doItContext]
  ifFalse: [rcvr := ctxt := nil].
 
  selectionInterval := self selectionInterval.
+ result := [
- result := [[
  rcvr class evaluatorClass new
  evaluate: self selectionAsStream
  in: ctxt
  to: rcvr
  environment: (model environment ifNil: [Smalltalk globals])
  notifying: self
  ifFail: [morph flash. ^ nil]
  logged: true.
  ]
  on: OutOfScopeNotification
+ do: [ :ex | ex resume: true].
+ "The parser might change the current selection for interactive error correction."
+ self selectInterval: selectionInterval.
- do: [ :ex | ex resume: true]
- ]
- ensure: [
- "The parser might change the current selection for interactive error correction."
- self selectInterval: selectionInterval].
 
  (model respondsTo: #expressionEvaluated:result:) ifTrue: [
  model perform: #expressionEvaluated:result: with: self selection with: result].
 
  ^aBlock value: result!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.1608.mcz

marcel.taeumel
This was the bug:



Yet, I am not sure why that #ensure: block had such a strange side effect in #evaluateSelectionAndDo:. Because only the last line in the method creates and selects that print-it string.

Best,
Marcel

Best,
Marcel

Am 13.12.2019 10:02:47 schrieb [hidden email] <[hidden email]>:

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1608.mcz

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

Name: Morphic-mt.1608
Author: mt
Time: 13 December 2019, 10:02:28.682784 am
UUID: aefd108e-0a66-0041-a417-669c5b08df12
Ancestors: Morphic-mt.1607

Fixes a small glitch that I introduced in the last commit.

=============== Diff against Morphic-mt.1607 ===============

Item was changed:
----- Method: TextEditor>>evaluateSelectionAndDo: (in category 'do-its') -----
evaluateSelectionAndDo: aBlock
"Treat the current selection as an expression; evaluate it and invoke aBlock with the result."

| result rcvr ctxt selectionInterval |
self lineSelectAndEmptyCheck: [^ nil].

(model respondsTo: #evaluateExpression:) ifTrue: [
^ aBlock value: (model perform: #evaluateExpression: with: self selection)].

(model respondsTo: #doItReceiver)
ifTrue: [ rcvr := model doItReceiver.
ctxt := model doItContext]
ifFalse: [rcvr := ctxt := nil].

selectionInterval := self selectionInterval.
+ result := [
- result := [[
rcvr class evaluatorClass new
evaluate: self selectionAsStream
in: ctxt
to: rcvr
environment: (model environment ifNil: [Smalltalk globals])
notifying: self
ifFail: [morph flash. ^ nil]
logged: true.
]
on: OutOfScopeNotification
+ do: [ :ex | ex resume: true].
+ "The parser might change the current selection for interactive error correction."
+ self selectInterval: selectionInterval.
- do: [ :ex | ex resume: true]
- ]
- ensure: [
- "The parser might change the current selection for interactive error correction."
- self selectInterval: selectionInterval].

(model respondsTo: #expressionEvaluated:result:) ifTrue: [
model perform: #expressionEvaluated:result: with: self selection with: result].

^aBlock value: result!




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.1608.mcz

Christoph Thiede

I think I understand the bug and its fix, but I don't understand your comment about the "strange side effect":

Afaik compilation error strings are generated by the parser (see #notify:at:[in:])? So before your latest commit, the following happened:

  1. #notify:at:in: prints the error string
  2. the fail block [morph flash. ^ nil] is evaluated
  3. while returning, the ensure block is called to restore the previous selection
  4. the do block passed from #printIt is *not* called, so the selection will not be changed again.
So what side effect are you referring to? :-)

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Freitag, 13. Dezember 2019 10:11:07
An: John Pfersich via Squeak-dev
Betreff: Re: [squeak-dev] The Trunk: Morphic-mt.1608.mcz
 
This was the bug:



Yet, I am not sure why that #ensure: block had such a strange side effect in #evaluateSelectionAndDo:. Because only the last line in the method creates and selects that print-it string.

Best,
Marcel

Best,
Marcel

Am 13.12.2019 10:02:47 schrieb [hidden email] <[hidden email]>:

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1608.mcz

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

Name: Morphic-mt.1608
Author: mt
Time: 13 December 2019, 10:02:28.682784 am
UUID: aefd108e-0a66-0041-a417-669c5b08df12
Ancestors: Morphic-mt.1607

Fixes a small glitch that I introduced in the last commit.

=============== Diff against Morphic-mt.1607 ===============

Item was changed:
----- Method: TextEditor>>evaluateSelectionAndDo: (in category 'do-its') -----
evaluateSelectionAndDo: aBlock
"Treat the current selection as an expression; evaluate it and invoke aBlock with the result."

| result rcvr ctxt selectionInterval |
self lineSelectAndEmptyCheck: [^ nil].

(model respondsTo: #evaluateExpression:) ifTrue: [
^ aBlock value: (model perform: #evaluateExpression: with: self selection)].

(model respondsTo: #doItReceiver)
ifTrue: [ rcvr := model doItReceiver.
ctxt := model doItContext]
ifFalse: [rcvr := ctxt := nil].

selectionInterval := self selectionInterval.
+ result := [
- result := [[
rcvr class evaluatorClass new
evaluate: self selectionAsStream
in: ctxt
to: rcvr
environment: (model environment ifNil: [Smalltalk globals])
notifying: self
ifFail: [morph flash. ^ nil]
logged: true.
]
on: OutOfScopeNotification
+ do: [ :ex | ex resume: true].
+ "The parser might change the current selection for interactive error correction."
+ self selectInterval: selectionInterval.
- do: [ :ex | ex resume: true]
- ]
- ensure: [
- "The parser might change the current selection for interactive error correction."
- self selectInterval: selectionInterval].

(model respondsTo: #expressionEvaluated:result:) ifTrue: [
model perform: #expressionEvaluated:result: with: self selection with: result].

^aBlock value: result!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-mt.1608.mcz

marcel.taeumel
>  the fail block [morph flash. ^ nil] is evaluated

Ah, that was it. Thanks.

Best,
Marcel

Am 13.12.2019 11:31:41 schrieb Thiede, Christoph <[hidden email]>:

I think I understand the bug and its fix, but I don't understand your comment about the "strange side effect":

Afaik compilation error strings are generated by the parser (see #notify:at:[in:])? So before your latest commit, the following happened:

  1. #notify:at:in: prints the error string
  2. the fail block [morph flash. ^ nil] is evaluated
  3. while returning, the ensure block is called to restore the previous selection
  4. the do block passed from #printIt is *not* called, so the selection will not be changed again.
So what side effect are you referring to? :-)

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Freitag, 13. Dezember 2019 10:11:07
An: John Pfersich via Squeak-dev
Betreff: Re: [squeak-dev] The Trunk: Morphic-mt.1608.mcz
 
This was the bug:



Yet, I am not sure why that #ensure: block had such a strange side effect in #evaluateSelectionAndDo:. Because only the last line in the method creates and selects that print-it string.

Best,
Marcel

Best,
Marcel

Am 13.12.2019 10:02:47 schrieb [hidden email] <[hidden email]>:

Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1608.mcz

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

Name: Morphic-mt.1608
Author: mt
Time: 13 December 2019, 10:02:28.682784 am
UUID: aefd108e-0a66-0041-a417-669c5b08df12
Ancestors: Morphic-mt.1607

Fixes a small glitch that I introduced in the last commit.

=============== Diff against Morphic-mt.1607 ===============

Item was changed:
----- Method: TextEditor>>evaluateSelectionAndDo: (in category 'do-its') -----
evaluateSelectionAndDo: aBlock
"Treat the current selection as an expression; evaluate it and invoke aBlock with the result."

| result rcvr ctxt selectionInterval |
self lineSelectAndEmptyCheck: [^ nil].

(model respondsTo: #evaluateExpression:) ifTrue: [
^ aBlock value: (model perform: #evaluateExpression: with: self selection)].

(model respondsTo: #doItReceiver)
ifTrue: [ rcvr := model doItReceiver.
ctxt := model doItContext]
ifFalse: [rcvr := ctxt := nil].

selectionInterval := self selectionInterval.
+ result := [
- result := [[
rcvr class evaluatorClass new
evaluate: self selectionAsStream
in: ctxt
to: rcvr
environment: (model environment ifNil: [Smalltalk globals])
notifying: self
ifFail: [morph flash. ^ nil]
logged: true.
]
on: OutOfScopeNotification
+ do: [ :ex | ex resume: true].
+ "The parser might change the current selection for interactive error correction."
+ self selectInterval: selectionInterval.
- do: [ :ex | ex resume: true]
- ]
- ensure: [
- "The parser might change the current selection for interactive error correction."
- self selectInterval: selectionInterval].

(model respondsTo: #expressionEvaluated:result:) ifTrue: [
model perform: #expressionEvaluated:result: with: self selection with: result].

^aBlock value: result!