Thread overview
scope failure
Jun 20, 2006
nobody
Jun 20, 2006
Regan Heath
Jun 20, 2006
nobody
Jun 20, 2006
BCS
Jun 20, 2006
BCS
Jun 20, 2006
Regan Heath
June 20, 2006
Hello,

i try to learn the scope statements.

import std.stdio;

void main() {
{
scope(failure) writefln("5");
//writefln("Hallo");
}
}

The output from the program is 5. If i comment the writefln in, then it only
print Hallo.
Is this the correct behavier?
I have thougt scope(failure) will only execute when the scope exit
abnormaly by throw. The 5 should never be occur by thi example.




June 20, 2006
On Tue, 20 Jun 2006 07:52:00 +0000 (UTC), nobody <nobody_member@pathlink.com> wrote:
> i try to learn the scope statements.
>
> import std.stdio;
>
> void main() {
> {
> scope(failure) writefln("5");
> //writefln("Hallo");
> }
> }
>
> The output from the program is 5. If i comment the writefln in, then it only
> print Hallo.
> Is this the correct behavier?
> I have thougt scope(failure) will only execute when the scope exit
> abnormaly by throw. The 5 should never be occur by thi example.

It seems to trigger when the scope is empty, putting any other valid statement in the scope with the scope(failure) statement stops the output of "5". I suspect this is a bug.

Regan
June 20, 2006
In article <optbfpq9sx23k2f5@nrage>, Regan Heath says...
>
>On Tue, 20 Jun 2006 07:52:00 +0000 (UTC), nobody <nobody_member@pathlink.com> wrote:
>> i try to learn the scope statements.
>>
>> import std.stdio;
>>
>> void main() {
>> {
>> scope(failure) writefln("5");
>> //writefln("Hallo");
>> }
>> }
>>
>> The output from the program is 5. If i comment the writefln in, then it
>> only
>> print Hallo.
>> Is this the correct behavier?
>> I have thougt scope(failure) will only execute when the scope exit
>> abnormaly by throw. The 5 should never be occur by thi example.
>
>It seems to trigger when the scope is empty, putting any other valid statement in the scope with the scope(failure) statement stops the output of "5". I suspect this is a bug.
>
>Regan


He, funny
Under dmd 161, it run correct now.

Thank you


June 20, 2006
nobody wrote:
> In article <optbfpq9sx23k2f5@nrage>, Regan Heath says...
> 
>>On Tue, 20 Jun 2006 07:52:00 +0000 (UTC), nobody  <nobody_member@pathlink.com> wrote:
>>
>>>i try to learn the scope statements.
>>>
>>>import std.stdio;
>>>
>>>void main() {
>>>{
>>>scope(failure) writefln("5");
>>>//writefln("Hallo");
>>>}
>>>}
>>>
>>>The output from the program is 5. If i comment the writefln in, then it  only
>>>print Hallo.
>>>Is this the correct behavier?
>>>I have thougt scope(failure) will only execute when the scope exit
>>>abnormaly by throw. The 5 should never be occur by thi example.
>>
>>It seems to trigger when the scope is empty, putting any other valid  statement in the scope with the scope(failure) statement stops the output  of "5". I suspect this is a bug.
>>
>>Regan
> 
> 
> 
> He, funny
> Under dmd 161, it run correct now.
> 
> Thank you
> 
> 
June 20, 2006
Sorry for that empty post <:-P

What might be happening (under 0.160) is that under some conditions DMD will insert an assert(0) at then end of a function to catch the no-return-statement bug. It's not supposed to do that with a void function but who knows.


nobody wrote:
> In article <optbfpq9sx23k2f5@nrage>, Regan Heath says...
> 
>>On Tue, 20 Jun 2006 07:52:00 +0000 (UTC), nobody  <nobody_member@pathlink.com> wrote:
>>
>>>i try to learn the scope statements.
>>>
>>>import std.stdio;
>>>
>>>void main() {
>>>{
>>>scope(failure) writefln("5");
>>>//writefln("Hallo");
>>>}
>>>}
>>>
>>>The output from the program is 5. If i comment the writefln in, then it  only
>>>print Hallo.
>>>Is this the correct behavier?
>>>I have thougt scope(failure) will only execute when the scope exit
>>>abnormaly by throw. The 5 should never be occur by thi example.
>>
>>It seems to trigger when the scope is empty, putting any other valid  statement in the scope with the scope(failure) statement stops the output  of "5". I suspect this is a bug.
>>
>>Regan
> 
> 
> 
> He, funny
> Under dmd 161, it run correct now.
> 
> Thank you
> 
> 
June 20, 2006
On Tue, 20 Jun 2006 08:59:53 -0700, BCS <BCS@pathlink.com> wrote:
> Sorry for that empty post <:-P
>
> What might be happening (under 0.160) is that under some conditions DMD will insert an assert(0) at then end of a function to catch the no-return-statement bug. It's not supposed to do that with a void function but who knows.

I thought that at first, but there are 2 scopes involved. The main function and a 2nd scope inside it. The scope(failure) is inside the 2nd scope so should trigger if there is an exception in that scope, not if there is one in main. I added a return value to double check :)

Regan

>
> nobody wrote:
>> In article <optbfpq9sx23k2f5@nrage>, Regan Heath says...
>>
>>> On Tue, 20 Jun 2006 07:52:00 +0000 (UTC), nobody  <nobody_member@pathlink.com> wrote:
>>>
>>>> i try to learn the scope statements.
>>>>
>>>> import std.stdio;
>>>>
>>>> void main() {
>>>> {
>>>> scope(failure) writefln("5");
>>>> //writefln("Hallo");
>>>> }
>>>> }
>>>>
>>>> The output from the program is 5. If i comment the writefln in, then it  only
>>>> print Hallo.
>>>> Is this the correct behavier?
>>>> I have thougt scope(failure) will only execute when the scope exit
>>>> abnormaly by throw. The 5 should never be occur by thi example.
>>>
>>> It seems to trigger when the scope is empty, putting any other valid  statement in the scope with the scope(failure) statement stops the output  of "5". I suspect this is a bug.
>>>
>>> Regan
>>    He, funny
>> Under dmd 161, it run correct now.
>>  Thank you
>>