From: Robert Dober Date: 2006-07-07T02:42:35+09:00 Subject: Re: [Bug?] Confused exception handling in Continuation Context ------=_Part_75238_12477694.1152207751877 Content-Type: multipart/alternative; boundary="----=_Part_75239_30973081.1152207751877" ------=_Part_75239_30973081.1152207751877 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/6/06, Yukihiro Matsumoto wrote: > > Hi, > > In message "Re: [Bug?] Confused exception handling in Continuation > Context" > on Thu, 6 Jul 2006 21:04:25 +0900, "Robert Dober" < > robert.dober@gmail.com> writes: > > > Ok here we go again. I have the feeling that my limitted understanding of continuations puts you off the track. As a matter of fact I do not complain that there is an exception, this exception is intentional, I complain that it is handled/rescued when it shall not. But please kindly forget about the much too complicated example above. Let us look at this: ------------------------8<-------------------------- cat iter3.rb #!/usr/bin/env ruby class DemonstrationError < Exception; end $next = nil def will_raise return $next.call if $next loop do callcc{ |$next| raise DemonstrationError } end # do end # def will_raise puts "In the beginning..." begin puts "First loop..." will_raise rescue DemonstrationError puts "Caught in first loop..." end puts "After first block, but now we will not catch the exception!!!" ### This should raise an *uncaught* Exception will_raise ------------------------ 8<------------------------------ Do you agree that (a) the continuation object in $next will be defined forever after the first call of will_raise? (b) every invocation of $next (triggered by will_raise) will raise a DemonstrationError? (c) the first invocation of $next (triggered by will_raise) will be handled in the rescue clause? (d) the second invocation of $next (triggered by will_raise) will not be handled? in that case this code should execute each puts statement exactly once and then fail with an uncaught DemonstrationError? If you are not in agreement could you please explain the behavior? Ty again Robert ------=_Part_75239_30973081.1152207751877 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 7/6/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,

In message "Re: [Bug?] Confused exception handling in Continuation Context"
    on Thu, 6 Jul 2006 21:04:25 +0900, "Robert Dober" <robert.dober@gmail.com > writes:

<SNIP>

Ok here we go again.
I have the feeling that my limitted understanding of continuations puts you off the track. As a matter of fact I do not complain that there is an exception, this exception is intentional, I complain that it is handled/rescued when it shall not.
But please kindly forget about the much too complicated example above.
Let us look at this:
------------------------8<--------------------------
cat iter3.rb
#!/usr/bin/env ruby

class DemonstrationError < Exception; end
$next = nil
def will_raise
        return $next.call if $next
        loop do
                callcc{ |$next|
                        raise DemonstrationError
                }
        end # do
end # def will_raise

puts "In the beginning..."
begin
        puts "First loop..."
        will_raise
rescue DemonstrationError
        puts "Caught in first loop..."
end

puts "After first block, but now we will not catch the exception!!!"
### This should raise an *uncaught* Exception
will_raise
------------------------ 8<------------------------------

Do you agree that
(a) the continuation object in $next will be defined forever after the first call of will_raise?
(b) every invocation of $next (triggered by will_raise) will raise a DemonstrationError?
(c) the first invocation of $next (triggered by will_raise) will  be handled in the rescue clause?
(d) the second invocation of $next (triggered by will_raise) will not be handled?

in that case this code should execute each puts statement exactly once and
then fail with an uncaught DemonstrationError?

If you are not in agreement could you please explain the behavior?

Ty again
Robert
------=_Part_75239_30973081.1152207751877-- ------=_Part_75238_12477694.1152207751877 Content-Type: application/x-bzip2; name=iter3.tar.bz2 Content-Transfer-Encoding: base64 X-Attachment-Id: f_epbelpr6 Content-Disposition: attachment; filename="iter3.tar.bz2" QlpoOTFBWSZTWf0DvS4AAY5/lMQwAQB8Vf+OLyAMQP/v3+4QAAACAAhAAh1SFCCSRUfqYaNSeo09 T0jQAeoBoGIxNNDmmJgATABMAAJgACYc0xMACYAJgABMAATBFIQySn6p+gptR6j1NDQeppoBkDTT aJ+SkcNR3zIVaXCichFwbY27onMoGRCgSMBFmYGYZq/36z7JUZ8uJn5XPdyBSmHxzOi8wT4Sgq7Y OsMjqwMC7Oxh6Pdy0bk9SQk+uOFyWTQmzAG9yHIlqrgaEa0UIsNmMCCGJY3MWg9ja657Nku3n60T CC1GpmbdOw4q65z0DqR2sBm0SE8L3UxNPqSJNSA+1rovKTyIvPgWKxeVClYPlXGItOYZ+E2hzwES ZsE57orSOYINI9hTkLppR6klK150B0yE47/pNM9HcuSWTHhbKoVus3pojgvBOc+7+mtY06sl0rgG swTMOPQTE/aUNQ0bJZLVZeKeaxA96KtweYBHmg0jYtgtO2tFlwhzWX0QjJNua7G7zbcJp2lElAWv D/BQr4iRIS9u3mIZJeJ3sgLwKNU18skoBZfPpImaSKJ5YO4L89zjamvmOJm9zsB8AaNAZUpA0tnU GRpZEoPWVTUmtJLckqSmYJvTExXpWjc3hGanjgKOuXXtIcqIVBY5Eki1rcWFDME08YQtSA/xdyRT hQkP0DvS4A== ------=_Part_75238_12477694.1152207751877--