{Spam?} bug with iterate

View: New views
2 Messages — Rating Filter:   Alert me  

{Spam?} bug with iterate

by Ralf Hemmecke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

that looks like a bug to me.

By mistake I've put an 'iterate' not in a 'repeat' body.
I think the compiler should reject that program instead of compiling it
and then looping forever when I running the program.

Ralf

aldor -fx -laldor bugIterate.as
bugIterate
foo0 = 1
foo1 = 1
foo0 = 2
-- program doesn't stop


---BEGIN bugIterate.as
#include "aldor"
#include "aldorio"
import from Integer;
foo(i: Integer): () == {
        stdout << "foo0 = " << i << newline;
        if even? i then iterate;
        stdout << "foo1 = " << i << newline;
}
main(): () == for i in 1..5 repeat foo(i);
main();
---END bugIterate.as

_______________________________________________
Aldor-l mailing list
Aldor-l@...
http://aldor.org/mailman/listinfo/aldor-l_aldor.org

Parent Message unknown Re: {Spam?} bug with iterate

by Ralf Hemmecke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

I somehow don't see your messages recorded on the aldor-l archive.
Aren't you subscribed?

Ralf

On 07/11/2008 12:15 PM, Peter Broadbery wrote:

> On Thu, Jul 10, 2008 at 5:29 AM, Ralf Hemmecke <ralf@...> wrote:
>> Hello,
>>
>> that looks like a bug to me.
>>
>> By mistake I've put an 'iterate' not in a 'repeat' body.
>> I think the compiler should reject that program instead of compiling it
>> and then looping forever when I running the program.
>>
>> Ralf
>>
>> aldor -fx -laldor bugIterate.as
>> bugIterate
>> foo0 = 1
>> foo1 = 1
>> foo0 = 2
>> -- program doesn't stop
>>
>>
>> ---BEGIN bugIterate.as
>> #include "aldor"
>> #include "aldorio"
>> import from Integer;
>> foo(i: Integer): () == {
>>        stdout << "foo0 = " << i << newline;
>>        if even? i then iterate;
>>        stdout << "foo1 = " << i << newline;
>> }
>> main(): () == for i in 1..5 repeat foo(i);
>> main();
>> ---END bugIterate.as
>>
>
> Looks to be an unimplemented check, with code generation producing
> something daft.  The obvious fix is to add some code to recognise an
> iterate (or break) that's not within a repeat clause - the code would
> go into abcheck.c.  Only difficulty is in ensuring that one follows
> the syntax correctly - a break would be allowed only within contained
> sequence, conditions, exit clauses, try/catch clauses and probably one
> or two constructs.
>
> Peter


_______________________________________________
Aldor-l mailing list
Aldor-l@...
http://aldor.org/mailman/listinfo/aldor-l_aldor.org
LightInTheBox - Buy quality products at wholesale price