You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The IF command outputs the result of the instruction list if the condition is TRUE.
That enables the user to, for example:
MAKE "MESSAGE IF :USERNAME = "jsmith ["Welcome!]
PRINT :MESSAGE
What is the output if the condition is FALSE?
Of course, my example IS bad programming practice and probably should result in an error. It's just that the error message is unclear; an empty list is a list.
? show if "false ["hello]
Macro returned [] instead of a list
The text was updated successfully, but these errors were encountered:
Oh gosh it's a terrible error message, because a user of IF shouldn't have to know what a macro is! Really the message should be IF DIDN'T OUTPUT TO SHOW. Sorry!
The case of an IF with no else clause, when a value is expected, could be caught in advance with IF (VAL_STATUS == VALUE_OK) at coms.c line 236. That would be the usual thing, although Logo's general practice is to report errors as late as possible so that side effects happen. But this could be viewed as a syntax error I guess.
I suppose it could be a syntax error, but I agree that the most sensible error should be IF didn't output to SHOW.
It seems that after IF checks the condition, it outputs a list to be run as a macro. If the condition is FALSE the list will be empty. So UCBLogo treats:
IF tf instructionlist
as if the user wrote:
IFELSE tf instructionlist []
After some poking around, I found similar issues in a few other places. This is probably the simplest example:
SHOW RUN []
Macro returned [] instead of a list
It also happens when using IFT and IFF.
Oh, and don't feel sorry. UCBLogo is an excellent interpreter and language. As you guys probably know, I'm building my own interpreter, and I'm poking around UCBLogo testing edge cases.
The
IF
command outputs the result of the instruction list if the condition isTRUE
.That enables the user to, for example:
What is the output if the condition is
FALSE
?Of course, my example IS bad programming practice and probably should result in an error. It's just that the error message is unclear; an empty list is a list.
The text was updated successfully, but these errors were encountered: