Re: loop do .. until end loop is surely incorrect!

new topic     » goto parent     » topic index » view thread      » older message » newer message
bill said...
loop do  
  integer x = 3  
  until x = 3  
end loop  

According to the manual this is correct.

It does NOT compile. version 4.0.0 on linux (slackware 13.1).

The manual is a bit ambiguous. The until is really a part of the end loop statement. The docs should be clarified.

bill said...

That is to say that it should compile, and the reason it doesn't has probably due to its being seen as a variation on a while loop - (but there the test comes after the end loop).

I do not like the loop scoping rules in Euphoria because they depend on syntax: where the loop ends, when the dynamics would indicate that the scope should be from declaration to the exit from the loop.

I still disagree. The body of the loop is its own scope. The loops beginning and ending are outside of that scope. The loop's test is part of either the beginning or ending statement of the loop.

bill said...

This ambiguity is problematic: eg.

while TRUE with entry do 
  integer x = 3 
entry 
  ? x 
end while 

will compile but not run because x has on value on the 1st iteration.

Yes, you shouldn't write code like that. It's really no different than:

integer x 
if foo() then 
    x = 1 
end if 
? x 

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu