Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000786Core InformPhrases and functional programmingpublic2011-10-31 10:342014-05-07 07:34
Assigned Tograham 
PlatformOSOS Version
Product Version6G60 
Target VersionFixed in Version6L02 
Summary0000786: The compiler doesn't accept the construct 'unless (condition), (phrase 1); otherwise (phrase 2).'
DescriptionThe attached code is rejected with the following error message:

Problem. You wrote 'otherwise say "You think about the apple."' : but inside an 'if ... begin'/'end if' an 'otherwise' (or 'else') must be a single word phrase, so it appears that the two ways to use 'otherwise' have been mixed up. It can either be used as 'if ... begin; ...; otherwise; ...; end if', or as 'if ..., ...; otherwise ...;'.
Minimal Source Text To Reproduce
The Lab is a room. The player carries an apple.

Instead of thinking:
	unless the apple is carried, say "You can't think of anything to think about.";
	otherwise say "You think about your apple."
Additional InformationIf we use "if not" instead of "unless" there's no problem:
Instead of thinking:
if the apple is not carried, say "You can't think of anything to think about.";
otherwise say "You think about your apple."

Using the block form works fine as well:
Instead of thinking:
unless the apple is carried:
say "You can't think of anything to think about.";
say "You think about your apple."
TagsNo tags attached.
Effect(serious) Compiler rejects valid code
Attached Files

- Relationships

-  Notes
EmacsUser (manager)
2011-11-02 13:07

Hmm. The relevant documentation is WI 11.8, in particular these bits:

- - - -
[Otherwise] can only be used as part of an "if ...:" or "unless: ...", and provides an alternative block of phrases to follow if the first block isn't followed.
- - - -

- - - -
When there is only a single phrase we can use the shortened form:
    if N is 2, say "Hooray, N is 2!";
    otherwise say "Boo, N is not 2...";
- - - -

So the first says that ``otherwise'' applies both to ``if'' and ``unless'' in block form, and the second gives a shortened form for ``if,'' possibly implying a similar shortened form for ``unless.'' I'll have to ask whether the attached source text is meant to be valid or the documentation is just unclear.
gnomon (reporter)
2011-11-02 14:32

You may be right, but in that case I'd say the documentation is very unclear about this limitation. Both of those quotes give an example using "if"; I would never have thought that significant, especially as it has already said (in 11.6) that "unless" can be used whenever "if" can.

Besides, (though this may just be ignorance on my part,) why would this phrase even be illegal in the first place? Isn't "unless" basically the same thing as "if" (just with the condition negated)? It just feels confusing and inconsistent that they can't be used the same way.
gnomon (reporter)
2011-11-02 14:47

Also, the error message is pretty unhelpful:
1) It says that "an 'otherwise' (or 'else') must be a single word phrase", which it already is (say "..."), and
2) the correct form it suggests ('if ..., ...; otherwise ...;') is exactly what was used, only with "unless" instead of "if".
EmacsUser (manager)
2011-11-03 09:37

Yes, this would be a weird asymmetry. For some reason I was reading the documentation very literally yesterday.
graham (administrator)
2014-01-12 13:36

Well, in fact, this _was_ a bug, but it's now gone and the example text produces correct code.

- Issue History
Date Modified Username Field Change
2011-10-31 10:34 gnomon New Issue
2011-11-02 13:00 EmacsUser Relationship added duplicate of 0000557
2011-11-02 13:01 EmacsUser Relationship deleted 0000557
2011-11-02 13:07 EmacsUser Note Added: 0001442
2011-11-02 14:32 gnomon Note Added: 0001444
2011-11-02 14:47 gnomon Note Added: 0001445
2011-11-03 09:37 EmacsUser Note Added: 0001446
2011-11-03 09:37 EmacsUser Status new => confirmed
2014-01-12 13:36 graham Note Added: 0002280
2014-01-12 13:36 graham Status confirmed => resolved
2014-01-12 13:36 graham Resolution open => fixed
2014-01-12 13:36 graham Assigned To => graham
2014-05-07 07:34 jmcgrew Fixed in Version => 6L02
2014-05-07 07:34 jmcgrew Status resolved => closed

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker