Re: Phix loop variables and scope
- Posted by _tom (admin) May 25, 2018
- 1096 views
Both languages say the same thing.
- 'x' is defined in the first line
- at the "top-level" you can not use 'x' in another definition (a loop variable is another definition of x)
The error messages compared:
- OE simply says you have used 'x' already
- Phix says because 'x' is already used, you better get a namespace qualifier if you try to define it in two places
So, the Phix wording is just an indirect way of showing you the same error.
integer x = 0 for x = 2 to 7 do ? x end for ? x /* OE <0031>:: attempt to redefine x. for x = 2 to 7 do ^ */ /* PHIX ? x ^ a namespace qualifier is required x is defined in: /media/oe/ORIGINAL/forum/loop variable/t01.ex, /media/oe/ORIGINAL/forum/loop variable/t01.ex. */
Both languages are ornary (stubbornly obstructive and unwilling to cooperate) about namespace use:
namespace mine integer mine:x /* OE error <0025>:: found ... variable ... but was expecting an identifier name integer mine:x ^ */ /* PHIX error integer mine:x ^ namespace qualifier not specific enough x is defined in: */ x = 0 ? x x += 1 ? mine:x
_tom