• Re: Accumulated and never suppressed exceptions (setup_call_cleanup/3)

    From Mostowski Collapse@21:1/5 to Mostowski Collapse on Tue Feb 21 12:20:11 2023
    As a bonus, all the setup_call_cleanup/3 test cases as per
    WG17 N215 should now pass, even in the presence of exception
    chaining, when they are written with the help of the new catch/3.

    The test case report shows me now:

    Ok Nok Predicate
    26 0 call_cleanup/2
    38 0 setup_call_cleanup/3

    BTW: What is the Python Exception Chaining? Check this out: https://docs.python.org/3/tutorial/errors.html#exception-chaining

    The thingy also works with the Logtalk idiom in Dogelog
    Player. There I now have as well the following behaviour,
    for the new once_cleanup/2:

    /* Dogelog Player 1.0.4 */
    ?- once_cleanup(throw(foo), throw(bar)).
    foo /* in red color */
    bar /* in red color */
    ?- catch(once_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.
    ?- sys_trap(once_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).

    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:15:20 UTC+1:
    Woa! 12 years later some new ideas! Holy Cow. Following
    the ideas of Python I have now a prototype where catch/3
    only matches the head of the chained exception:

    /* SWI-Prolog 9.1.4 */
    ?- call_cleanup(throw(foo), throw(bar)).
    ERROR: Unhandled exception: Unknown message: foo
    ERROR: Unhandled exception: Unknown message: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    /* Jekejeke Prolog 1.5.6 */
    ?- call_cleanup(throw(foo), throw(bar)).
    Unknown exception: foo
    Unknown exception: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    In case somebody wants to access the full chained
    exception, one can still use sys_trap/3:

    /* Jekejeke Prolog 1.5.6 */
    ?- sys_trap(call_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).

    Maybe this is less comfortable than Python, since the
    suggestion is two different catchers, catch/3 and sys_trap/3.
    Whereas Python has always the same catcher, but different throwers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to All on Tue Feb 21 12:15:18 2023
    Woa! 12 years later some new ideas! Holy Cow. Following
    the ideas of Python I have now a prototype where catch/3
    only matches the head of the chained exception:

    /* SWI-Prolog 9.1.4 */
    ?- call_cleanup(throw(foo), throw(bar)).
    ERROR: Unhandled exception: Unknown message: foo
    ERROR: Unhandled exception: Unknown message: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    /* Jekejeke Prolog 1.5.6 */
    ?- call_cleanup(throw(foo), throw(bar)).
    Unknown exception: foo
    Unknown exception: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    In case somebody wants to access the full chained
    exception, one can still use sys_trap/3:

    /* Jekejeke Prolog 1.5.6 */
    ?- sys_trap(call_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).

    Maybe this is less comfortable than Python, since the
    suggestion is two different catchers, catch/3 and sys_trap/3.
    Whereas Python has always the same catcher, but different throwers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Tue Feb 21 12:33:37 2023
    Ha Ha, Dogelog Player has thrown the cutter overboard,
    but keeps the exception chaining, at least for the Logtalk idiom.

    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:20:12 UTC+1:
    As a bonus, all the setup_call_cleanup/3 test cases as per
    WG17 N215 should now pass, even in the presence of exception
    chaining, when they are written with the help of the new catch/3.

    The test case report shows me now:

    Ok Nok Predicate
    26 0 call_cleanup/2
    38 0 setup_call_cleanup/3

    BTW: What is the Python Exception Chaining? Check this out: https://docs.python.org/3/tutorial/errors.html#exception-chaining

    The thingy also works with the Logtalk idiom in Dogelog
    Player. There I now have as well the following behaviour,
    for the new once_cleanup/2:

    /* Dogelog Player 1.0.4 */
    ?- once_cleanup(throw(foo), throw(bar)).
    foo /* in red color */
    bar /* in red color */
    ?- catch(once_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.
    ?- sys_trap(once_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).
    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:15:20 UTC+1:
    Woa! 12 years later some new ideas! Holy Cow. Following
    the ideas of Python I have now a prototype where catch/3
    only matches the head of the chained exception:

    /* SWI-Prolog 9.1.4 */
    ?- call_cleanup(throw(foo), throw(bar)).
    ERROR: Unhandled exception: Unknown message: foo
    ERROR: Unhandled exception: Unknown message: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    /* Jekejeke Prolog 1.5.6 */
    ?- call_cleanup(throw(foo), throw(bar)).
    Unknown exception: foo
    Unknown exception: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    In case somebody wants to access the full chained
    exception, one can still use sys_trap/3:

    /* Jekejeke Prolog 1.5.6 */
    ?- sys_trap(call_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).

    Maybe this is less comfortable than Python, since the
    suggestion is two different catchers, catch/3 and sys_trap/3.
    Whereas Python has always the same catcher, but different throwers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Tue Feb 21 16:49:13 2023
    I blame it on the stars, 2011 was A Year of the Cat and
    so is 2023. It is believed to bring good luck and smooth sailing.

    al stewart 1979 long live version
    https://www.youtube.com/watch?v=AazEMt0eoFg

    Lets make 2023 a splendid year for all Prolog systems!

    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:33:38 UTC+1:
    Ha Ha, Dogelog Player has thrown the cutter overboard,
    but keeps the exception chaining, at least for the Logtalk idiom.
    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:20:12 UTC+1:
    As a bonus, all the setup_call_cleanup/3 test cases as per
    WG17 N215 should now pass, even in the presence of exception
    chaining, when they are written with the help of the new catch/3.

    The test case report shows me now:

    Ok Nok Predicate
    26 0 call_cleanup/2
    38 0 setup_call_cleanup/3

    BTW: What is the Python Exception Chaining? Check this out: https://docs.python.org/3/tutorial/errors.html#exception-chaining

    The thingy also works with the Logtalk idiom in Dogelog
    Player. There I now have as well the following behaviour,
    for the new once_cleanup/2:

    /* Dogelog Player 1.0.4 */
    ?- once_cleanup(throw(foo), throw(bar)).
    foo /* in red color */
    bar /* in red color */
    ?- catch(once_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.
    ?- sys_trap(once_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).
    Mostowski Collapse schrieb am Dienstag, 21. Februar 2023 um 21:15:20 UTC+1:
    Woa! 12 years later some new ideas! Holy Cow. Following
    the ideas of Python I have now a prototype where catch/3
    only matches the head of the chained exception:

    /* SWI-Prolog 9.1.4 */
    ?- call_cleanup(throw(foo), throw(bar)).
    ERROR: Unhandled exception: Unknown message: foo
    ERROR: Unhandled exception: Unknown message: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    /* Jekejeke Prolog 1.5.6 */
    ?- call_cleanup(throw(foo), throw(bar)).
    Unknown exception: foo
    Unknown exception: bar
    ?- catch(call_cleanup(throw(foo), throw(bar)), E, true).
    E = foo.

    In case somebody wants to access the full chained
    exception, one can still use sys_trap/3:

    /* Jekejeke Prolog 1.5.6 */
    ?- sys_trap(call_cleanup(throw(foo), throw(bar)), E, true).
    E = cause(foo, bar).

    Maybe this is less comfortable than Python, since the
    suggestion is two different catchers, catch/3 and sys_trap/3.
    Whereas Python has always the same catcher, but different throwers.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)