Search code examples
ozmozart

Why doesn't "for X in E1..E2;E3 do" work in Oz?


I'm using Mozart 2.0.0 and I'm following these docs: http://mozart.github.io/mozart-v1/doc-1.4.0/loop/node1.html#chapter.official

I'm guessing the loop syntax has changed or something, because I get a parse error when following the documentation exactly:

X in E1..E2;E3

My attempt:

for X in 5..1;-1 do
   {Browse X}
end

I eventually got it to work with the more verbose syntax:

for X in ({Length L};X > 0;X - 1) do
   {Browse X}
end

But the first example seems way more readable and less error prone to me. Why doesn't it work?


Solution

  • I did not test with 2.0.0, but in 1.4.0 it works if you replace - with ~.

    It's just another bit of unusual Oz syntax: the unary minus sign is always ~.

    - is only used for binary minus.