2

The Oz Compiler launch an exception "Missing Else Clause" when I try to compile this code, can anybody tell me why? Here is my code :

declare
fun {Numero x y}
   local NumeroAux in
      fun {NumeroAux x y Acc}
     if {And (x == 0) (y == 0)} then Acc
     else
        if y == 0 then {NumeroAux 0 x-1 Acc+1} 
        else
           {NumeroAux x+1 y-1 Acc+1}
        end
     end
      end
      {NumeroAux x y 0}
   end
end

{Browse {Numero 0 0}}

In my opinion, there isn't a missing else clause in this code! My function will always return something.

Makyen
  • 31,849
  • 12
  • 86
  • 121
anpar
  • 143
  • 7
  • 1
    Finally catch the error.. I forgot that variables in Oz must start with a capital letter... But I don't understand why the Oz Compiler says "Missing Else Clause" instead of something like "Variables must start with a capital letter"... – anpar Oct 02 '14 at 18:31

1 Answers1

2

In Oz language, all the variables need a uppercase. Lowercase is for atom's. So if you try to run your code with uppercases:

    declare
    fun {Numero X Y}
    local NumeroAux in
      fun {NumeroAux X Y Acc}
     if {And (X == 0) (Y == 0)} then Acc
     else
        if Y == 0 then {NumeroAux 0 X-1 Acc+1} 
        else
           {NumeroAux X+1 Y-1 Acc+1}
        end
     end
      end
      {NumeroAux Y X 0}
   end
end

{Browse {Numero 0 0}}

This will browse 0 as expected.

obronchain
  • 36
  • 4