The Trunk: System-cmm.694.mcz

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

The Trunk: System-cmm.694.mcz

commits-2
Chris Muller uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-cmm.694.mcz

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

Name: System-cmm.694
Author: cmm
Time: 16 January 2015, 3:44:19.079 pm
UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
Ancestors: System-dtl.693

- #flush stdout and stderr after writing error information to them.
- After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.

=============== Diff against System-dtl.693 ===============

Item was changed:
  ----- Method: SmalltalkImage>>run: (in category 'command line') -----
+ run: aBlock
- run: aBlock
  [ [ (aBlock numArgs = 1 and: [ self arguments size > 1 ])
+ ifTrue: [ "Allow a large, variable number of arguments to be passed as an Array to aBlock."
- ifTrue:
- [ "Allow a large, variable number of arguments to be passed as an Array to aBlock."
  aBlock value: self arguments ]
  ifFalse: [ aBlock valueWithEnoughArguments: self arguments ] ]
  on: ProgressInitiationException
  do:
  [ : pie | "Don't want to log this notification."
  pie defaultAction ] ]
  on: Notification , Warning
  do:
  [ : noti | FileStream stdout
  nextPutAll: DateAndTime now asString ;
  space ;
  nextPutAll: noti description ;
  cr.
  noti resume ]
  on: SyntaxErrorNotification
  do:
  [ : err | FileStream stdout
  nextPutAll: err errorCode ;
+ cr; flush.
- cr.
  self haltOrQuit ]
  on: Error
  do:
  [ : err | err printVerboseOn: FileStream stderr.
+ FileStream stderr flush.
+ (err isResumable and: [ (err isKindOf: MessageNotUnderstood) not ])
+ ifTrue: [ err resume ]
+ ifFalse: [ self haltOrQuit ] ]!
- self haltOrQuit.
- err isResumable ifTrue: [ err resume ] ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Frank Shearar-3
On 16 January 2015 at 21:44,  <[hidden email]> wrote:

> Chris Muller uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-cmm.694.mcz
>
> ==================== Summary ====================
>
> Name: System-cmm.694
> Author: cmm
> Time: 16 January 2015, 3:44:19.079 pm
> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
> Ancestors: System-dtl.693
>
> - #flush stdout and stderr after writing error information to them.
> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.

Why? It's probably a rare use case for a #run: script to catch MNUs to
do something fancy, I guess? Maybe it's because #run: is usually
(always?) the top level of the program?

Catching only MNUs seems very specific. Maybe there could be a #run:
version that says "and here's a function you can use to control which
exceptions are OK to resume, and which not"?

frank

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Eliot Miranda-2
Hi Frank,

On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:

> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>> Chris Muller uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>
>> ==================== Summary ====================
>>
>> Name: System-cmm.694
>> Author: cmm
>> Time: 16 January 2015, 3:44:19.079 pm
>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>> Ancestors: System-dtl.693
>>
>> - #flush stdout and stderr after writing error information to them.
>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>
> Why? It's probably a rare use case for a #run: script to catch MNUs to
> do something fancy, I guess? Maybe it's because #run: is usually
> (always?) the top level of the program?

One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.

>
> Catching only MNUs seems very specific. Maybe there could be a #run:
> version that says "and here's a function you can use to control which
> exceptions are OK to resume, and which not"?

Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?

Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.

So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

>
> frank

Eliot (phone)
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Eliot Miranda-2
Hi,

On Sat, Jan 17, 2015 at 10:35 AM, Eliot Miranda <[hidden email]> wrote:
Hi Frank,

On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:

> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>> Chris Muller uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>
>> ==================== Summary ====================
>>
>> Name: System-cmm.694
>> Author: cmm
>> Time: 16 January 2015, 3:44:19.079 pm
>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>> Ancestors: System-dtl.693
>>
>> - #flush stdout and stderr after writing error information to them.
>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>
> Why? It's probably a rare use case for a #run: script to catch MNUs to
> do something fancy, I guess? Maybe it's because #run: is usually
> (always?) the top level of the program?

One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.

>
> Catching only MNUs seems very specific. Maybe there could be a #run:
> version that says "and here's a function you can use to control which
> exceptions are OK to resume, and which not"?

Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?

Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.

So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

>
> frank

Eliot (phone)

See the Error handler in SmalltalkImage>>run:

                on: Error
                do:
                        [ : err | err printVerboseOn: FileStream stderr.
+                       FileStream stderr flush.
+                       (err isResumable and: [ (err isKindOf: MessageNotUnderstood) not ])
+                               ifTrue: [ err resume ]
+                               ifFalse: [ self haltOrQuit ] ]!
-                       self haltOrQuit.
-                       err isResumable ifTrue: [ err resume ] ]! 


IMO, this should read

               on: Error
               do:
                        [ : err |
                         err printVerboseOn: FileStream stderr.
                         FileStream stderr flush.
                         self haltOrQuit]! 

Resuming is definitely not safe; it could cause the software to attempt something damaging right?  And whatever is caught here is an error, no haltOrWuit is the only valid response, no?  I'm happy to make the change.
--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Chris Muller-3
In reply to this post by Frank Shearar-3


On Sat, Jan 17, 2015 at 5:39 AM, Frank Shearar <[hidden email]> wrote:
On 16 January 2015 at 21:44,  <[hidden email]> wrote:
> Chris Muller uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-cmm.694.mcz
>
> ==================== Summary ====================
>
> Name: System-cmm.694
> Author: cmm
> Time: 16 January 2015, 3:44:19.079 pm
> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
> Ancestors: System-dtl.693
>
> - #flush stdout and stderr after writing error information to them.
> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.

Why? It's probably a rare use case for a #run: script to catch MNUs to
do something fancy, I guess? Maybe it's because #run: is usually
(always?) the top level of the program?

Exactly.  #run: is for initiating long-running batch processes, typically in headless mode.
 

Catching only MNUs seems very specific. Maybe there could be a #run:
version that says "and here's a function you can use to control which
exceptions are OK to resume, and which not"?

It could, but the goal is for #run: to make it easy to run batch operations and do-the-right-thing while demanding the bare minimum of configuration from the user.

I smell the same thing you do.  I really don't like the smell of MessageNotUnderstood check, but let me explain my rationale in response to Eliots note and we can go from there.
 

frank




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Chris Muller-3
In reply to this post by Eliot Miranda-2
On Sat, Jan 17, 2015 at 4:03 PM, Eliot Miranda <[hidden email]> wrote:
Hi,

On Sat, Jan 17, 2015 at 10:35 AM, Eliot Miranda <[hidden email]> wrote:
Hi Frank,

On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:

> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>> Chris Muller uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>
>> ==================== Summary ====================
>>
>> Name: System-cmm.694
>> Author: cmm
>> Time: 16 January 2015, 3:44:19.079 pm
>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>> Ancestors: System-dtl.693
>>
>> - #flush stdout and stderr after writing error information to them.
>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>
> Why? It's probably a rare use case for a #run: script to catch MNUs to
> do something fancy, I guess? Maybe it's because #run: is usually
> (always?) the top level of the program?

One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.

>
> Catching only MNUs seems very specific. Maybe there could be a #run:
> version that says "and here's a function you can use to control which
> exceptions are OK to resume, and which not"?

Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?

Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.

So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

>
> frank

Eliot (phone)

See the Error handler in SmalltalkImage>>run:

                on: Error
                do:
                        [ : err | err printVerboseOn: FileStream stderr.
+                       FileStream stderr flush.
+                       (err isResumable and: [ (err isKindOf: MessageNotUnderstood) not ])
+                               ifTrue: [ err resume ]
+                               ifFalse: [ self haltOrQuit ] ]!
-                       self haltOrQuit.
-                       err isResumable ifTrue: [ err resume ] ]! 


IMO, this should read

               on: Error
               do:
                        [ : err |
                         err printVerboseOn: FileStream stderr.
                         FileStream stderr flush.
                         self haltOrQuit]! 

Resuming is definitely not safe; it could cause the software to attempt something damaging right?  And whatever is caught here is an error, no haltOrWuit is the only valid response, no?  I'm happy to make the change.

Actually, I think I should put it back to my original code.

               on: Error
               do:
                        [ : err |
                         err printVerboseOn: FileStream stderr.
                         FileStream stderr flush.
                         err isResumable ifTrue: [ self haltOrQuit ] ]! 

That way, if its headless, it'll exit every time.  If it's headful, the user will have the chance to fix the Error before clicking Proceed in the debugger.
 
--
best,
Eliot






Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Eliot Miranda-2

Hi Chris,

On Jan 17, 2015, at 4:45 PM, Chris Muller <[hidden email]> wrote:

On Sat, Jan 17, 2015 at 4:03 PM, Eliot Miranda <[hidden email]> wrote:
Hi,

On Sat, Jan 17, 2015 at 10:35 AM, Eliot Miranda <[hidden email]> wrote:
Hi Frank,

On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:

> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>> Chris Muller uploaded a new version of System to project The Trunk:
>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>
>> ==================== Summary ====================
>>
>> Name: System-cmm.694
>> Author: cmm
>> Time: 16 January 2015, 3:44:19.079 pm
>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>> Ancestors: System-dtl.693
>>
>> - #flush stdout and stderr after writing error information to them.
>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>
> Why? It's probably a rare use case for a #run: script to catch MNUs to
> do something fancy, I guess? Maybe it's because #run: is usually
> (always?) the top level of the program?

One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.

>
> Catching only MNUs seems very specific. Maybe there could be a #run:
> version that says "and here's a function you can use to control which
> exceptions are OK to resume, and which not"?

Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?

Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.

So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

>
> frank

Eliot (phone)

See the Error handler in SmalltalkImage>>run:

                on: Error
                do:
                        [ : err | err printVerboseOn: FileStream stderr.
+                       FileStream stderr flush.
+                       (err isResumable and: [ (err isKindOf: MessageNotUnderstood) not ])
+                               ifTrue: [ err resume ]
+                               ifFalse: [ self haltOrQuit ] ]!
-                       self haltOrQuit.
-                       err isResumable ifTrue: [ err resume ] ]! 


IMO, this should read

               on: Error
               do:
                        [ : err |
                         err printVerboseOn: FileStream stderr.
                         FileStream stderr flush.
                         self haltOrQuit]! 

Resuming is definitely not safe; it could cause the software to attempt something damaging right?  And whatever is caught here is an error, no haltOrWuit is the only valid response, no?  I'm happy to make the change.

Actually, I think I should put it back to my original code.

               on: Error
               do:
                        [ : err |
                         err printVerboseOn: FileStream stderr.
                         FileStream stderr flush.
                         err isResumable ifTrue: [ self haltOrQuit ] ]! 

That way, if its headless, it'll exit every time.  If it's headful, the user will have the chance to fix the Error before clicking Proceed in the debugger.

Agreed.  That's good behavior.  But it's entirely non-obvious that that's the effect of
       err isResumable ifTrue: [self haltOrQuit]

So there needs to be a comment immediately before that statement that explains what happens, just

"If we're headless, this will exit every time.  If we're headful, the user will have the chance to fix the Error before clicking Proceed in the debugger."

--
best,
Eliot







Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Frank Shearar-3
In reply to this post by Eliot Miranda-2
On 17 January 2015 at 18:35, Eliot Miranda <[hidden email]> wrote:

> Hi Frank,
>
> On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:
>
>> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>>> Chris Muller uploaded a new version of System to project The Trunk:
>>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: System-cmm.694
>>> Author: cmm
>>> Time: 16 January 2015, 3:44:19.079 pm
>>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>>> Ancestors: System-dtl.693
>>>
>>> - #flush stdout and stderr after writing error information to them.
>>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>>
>> Why? It's probably a rare use case for a #run: script to catch MNUs to
>> do something fancy, I guess? Maybe it's because #run: is usually
>> (always?) the top level of the program?
>
> One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.
>
>>
>> Catching only MNUs seems very specific. Maybe there could be a #run:
>> version that says "and here's a function you can use to control which
>> exceptions are OK to resume, and which not"?
>
> Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?
>
> Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.

Chris has already addressed the issue, but to continue the
conversation here, yes, an exception is resumable if e isResumable =
true. That's exactly as it should be. But seeing as an MNU  is
resumable, you could write a handler that _did_ return a value. In
other words, the problem that I saw - and I think Chris and you agree?
- is that it looks weird to resume some resumable exceptions but not
others.

I agree with the point you make in a later mail, that #run: should
just bail noisily on a top-level exception.

frank

>  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.
>
> So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

Yep.

>> frank
>
> Eliot (phone)

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Eliot Miranda-2


On Mon, Jan 19, 2015 at 1:59 AM, Frank Shearar <[hidden email]> wrote:
On 17 January 2015 at 18:35, Eliot Miranda <[hidden email]> wrote:
> Hi Frank,
>
> On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:
>
>> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>>> Chris Muller uploaded a new version of System to project The Trunk:
>>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: System-cmm.694
>>> Author: cmm
>>> Time: 16 January 2015, 3:44:19.079 pm
>>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>>> Ancestors: System-dtl.693
>>>
>>> - #flush stdout and stderr after writing error information to them.
>>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>>
>> Why? It's probably a rare use case for a #run: script to catch MNUs to
>> do something fancy, I guess? Maybe it's because #run: is usually
>> (always?) the top level of the program?
>
> One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.
>
>>
>> Catching only MNUs seems very specific. Maybe there could be a #run:
>> version that says "and here's a function you can use to control which
>> exceptions are OK to resume, and which not"?
>
> Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?
>
> Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.

Chris has already addressed the issue, but to continue the
conversation here, yes, an exception is resumable if e isResumable =
true. That's exactly as it should be. But seeing as an MNU  is
resumable, you could write a handler that _did_ return a value. In
other words, the problem that I saw - and I think Chris and you agree?
- is that it looks weird to resume some resumable exceptions but not
others.

I think we all agree on this.  There's no case for resuming anything other than Notification, Warning and subclasses.


I agree with the point you make in a later mail, that #run: should
just bail noisily on a top-level exception.

frank

>  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.
>
> So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

Yep.

>> frank
>
> Eliot (phone)




--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: System-cmm.694.mcz

Nicolas Cellier


2015-01-20 20:40 GMT+01:00 Eliot Miranda <[hidden email]>:


On Mon, Jan 19, 2015 at 1:59 AM, Frank Shearar <[hidden email]> wrote:
On 17 January 2015 at 18:35, Eliot Miranda <[hidden email]> wrote:
> Hi Frank,
>
> On Jan 17, 2015, at 3:39 AM, Frank Shearar <[hidden email]> wrote:
>
>> On 16 January 2015 at 21:44,  <[hidden email]> wrote:
>>> Chris Muller uploaded a new version of System to project The Trunk:
>>> http://source.squeak.org/trunk/System-cmm.694.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: System-cmm.694
>>> Author: cmm
>>> Time: 16 January 2015, 3:44:19.079 pm
>>> UUID: e79a2347-2f40-4fec-8f00-f67ecad68491
>>> Ancestors: System-dtl.693
>>>
>>> - #flush stdout and stderr after writing error information to them.
>>> - After that, if the exception is resumable (i.e. a Warning), resume it.  Except if its a MessageNotUnderstood -- that is not an error you want to resume in a headless environment.
>>
>> Why? It's probably a rare use case for a #run: script to catch MNUs to
>> do something fancy, I guess? Maybe it's because #run: is usually
>> (always?) the top level of the program?
>
> One reason is that resuming an MNU simply resends from the diesNotUnderstand: method, so resuming will result in infinite recursion.  I suppose the handler could allow one repeat but that seems arbitrary.  There's nothing to stop one including a resuming MNU handler in the expression if one wants to override the default behaviour.
>
>>
>> Catching only MNUs seems very specific. Maybe there could be a #run:
>> version that says "and here's a function you can use to control which
>> exceptions are OK to resume, and which not"?
>
> Well there is Notification and Warning but (rightly) MessageNotUnderstood is an Error.  Reporting Notifications and Warnings to the output and continuing, but aborting for other exceptions seems the right thing to do, rather than basing it in resumability, yes?  What am I missing?
>
> Whether an exception is resumability or not is to do with whether one can usefully provide a value with which to continue, not to do with the severity of the error.

Chris has already addressed the issue, but to continue the
conversation here, yes, an exception is resumable if e isResumable =
true. That's exactly as it should be. But seeing as an MNU  is
resumable, you could write a handler that _did_ return a value. In
other words, the problem that I saw - and I think Chris and you agree?
- is that it looks weird to resume some resumable exceptions but not
others.

I think we all agree on this.  There's no case for resuming anything other than Notification, Warning and subclasses.


It explains why some exceptions are resumable...
And why it's not allways a good idea to resume an exception just because it is resumable.

Nicolas


I agree with the point you make in a later mail, that #run: should
just bail noisily on a top-level exception.

frank

>  For example, being able to resume with nil for a permissions violation when opening a file or directory might make it really easy to implement a find(1) like search over directories where some may be unreadable due to permissions.  Being able to resume doesn't make the permissions violation any the less severe, but it dies give us a nice way if handling it, certainly less complex than having to explicitly check for permissions during the traversal.  Likewise, being able to substitute a value for an MNU allows all sorts of conveniences, eg see my code for disassembling methods to bytecode messages.
>
> So IMO the system should be reporting Notifications and Warnings and aborting for anything else.

Yep.

>> frank
>
> Eliot (phone)




--
best,
Eliot