I’m helping someone else with their project, and they ran into a small issue.
First, they created a property for people:
A person can be c, p, s, re, ri or x (this is the empowerment property). A person is usually x.
Later they want some logic along the following lines (though much simplified to minimize what I have to copy here):
After jumping:
if the player is:
-- c: say "C!";
-- p: say "P!";
-- s: say "S!";
-- re: say "RE!";
-- ri: say "RI!";
-- otherwise: say "X."
The compiler doesn’t like that, seeming to want the various items in each condition to be people. That’s reasonable enough, so I thought the following would fix it:
After jumping:
let z be the empowerment of the player;
say "<empowerment = [z]>[paragraph break]";
if z is:
-- c: say "C!";
-- p: say "P!";
-- s: say "S!";
-- re: say "RE!";
-- ri: say "RI!";
-- otherwise: say "X."
It does not fix it, and still won’t compile. So I suggested a different tack:
After jumping:
let z be the empowerment of the player;
if z is c:
say "C!";
otherwise if z is p:
say "P!";
otherwise if z is s:
say "S!";
otherwise if z is re:
say "RE!";
otherwise if z is ri:
say "RI!";
otherwise:
say "X."
I get the impression from the newly-resulting error message that the compiler is kind of trying to apply the property to itself to decide whether the condition is true. A different try, to see if it’s purely a matter of a misunderstanding caused by use of the temporary value:
After jumping:
if the empowerment of the player is c:
say "C!";
otherwise if the empowerment of the player is p:
say "P!";
otherwise if the empowerment of the player is s:
say "S!";
otherwise if the empowerment of the player is re:
say "RE!";
otherwise if the empowerment of the player is ri:
say "RI!";
otherwise:
say "X."
but this still generates an error. Perhaps the whole thing hinges on how the compiler is interpreting “is” in this kind of context?
The following version does work:
After jumping:
if the player is c:
say "C!";
otherwise if the player is p:
say "P!";
otherwise if the player is s:
say "S!";
otherwise if the player is re:
say "RE!";
otherwise if the player is ri:
say "RI!";
otherwise:
say "X."
So, my question is whether there is a good reason that any of the previous iterations didn’t work. It looks to me like what was finally accepted is the exact same logic as the original version, only not written in case-style block format. Perhaps the keyword “is” is allowed a different interpretation in an if-then-otherwise block than it is allowed in the case-style block format. If so, that seems like an inconsistency that would warrant a bug report.
Is there something more fundamental going on that I’m missing?