Anonymous  Login  Signup for a new account  20180117 17:34 PST 
Main  My View  View Issues  Change Log  Roadmap 
View Issue Details [ Jump to Notes ]  [ Issue History ] [ Print ]  
ID  Project  Category  View Status  Date Submitted  Last Update  
0001005  Core Inform  Equations, units, arithmetic  public  20120921 15:26  20140507 07:34  
Reporter  Victor Gijsbers  
Assigned To  graham  
Priority  normal  Severity  serious  Reproducibility  always  
Status  closed  Resolution  fixed  
Platform  x86  OS  Windows  OS Version  7  
Product Version  6G60  
Target Version  Fixed in Version  6L02  
Summary  0001005: Order of operations is not respected for arithmatic written in words  
Description  When you use words like "minus" and "divided by" instead of the arithmetical symbols, Inform 7 fails to take to order of operations into account. Thus, 6  4 / 2 will evaluate (correctly) to 4, while 6 minus 4 divided by 2 will evaluate (incorrectly) to 1. Obviously, this shouldn't happen.  
Minimal Source Text To Reproduce  "Say it with words" by Victor Gijsbers Mathematical laboratory is a room. When play begins: let n be 6  4 / 2; say "Obviously, 6 minus 4 divided by 2 is [n]."; let m be 6 minus 4 divided by 2; say "Unless, of course, it is [m]."  
Additional Information  More discussion, including people delving into the generated I6 code: http://www.intfiction.org/forum/viewtopic.php?f=7&t=5818 [^]  
Tags  No tags attached.  
Effect  (serious/mild) Game compiles but misbehaves  
Attached Files  
Relationships  

Notes  
(0001843) EmacsUser (manager) 20120921 18:37 
Confirmed, and possibly a duplicate of 0000776 in the sense that both problems stem from the Inform's limitation of one nonterminal per kind. 
(0001844) zarf (developer) 20120921 19:43 
I don't know enough about the parsing to know where nonterminals fit into this, but I see that 776 doesn't depend on whether the code uses words or symbols. This one does. Also, as climbingstars notes in the thread, order of operations is not just ignored but reversed here. showme 4 / 2 minus 6; ...prints 1 instead of 4. 
(0001845) EmacsUser (manager) 20120922 07:54 edited on: 20120922 09:46 
Right. But it's not a words vs. nonwords issue; cf.     When play begins: showme 4 * 2  6; showme 4  2 * 6.     As far as I can tell, Inform has a list of productions and goes through them until it can find one whose fixed words all appear. Then it recurses on the inbetween parts. The phrases here are tried in the order ``divided by'', ``'', ``/'', and ``minus'', which means that ``minus'' binds most tightly and ``divided by'' least tightly. 0000776 is turning out the way it does because Inform grabs onto the first occurrence of the fixed words, so ``1  2  3'' recurses on the ``2  3'', not the ``1  2''. I suppose I should mark some of the umbrella issues as related. The way almost all compilers solve both these problems is something like (pseudocode): To decide what arithmetic value [tier 2] is (X  an arithmetic value [tier 2]) minus (Y  an arithmetic value [tier 1]): ... To decide what arithmetic value [tier 1] is (X  an arithmetic value [tier 1]) divided by (Y  an arithmetic value [tier 0]): ... where expressions can be implicitly moved to higher tiers: To decide what arithmetic value [tier 2] is (X  an arithmetic value [tier 1]): ( {X} ). To decide what arithmetic value [tier 1] is (X  an arithmetic value [tier 0]): ( {X} ). and brackets convert expressions to tier 0: To decide what arithmetic value [tier 0] is ( (X  an arithmetic value [tier 2]) ): ( {X} ). So if Inform were to follow suit in some way, the same fix would squash this and 0000776, hence my comment. But yes, that probably doesn't make the bugs duplicates. 
(0002269) graham (administrator) 20140112 06:14 
This is by design. Arithmetic symbols obey the usual mathematical rules, but English doesn't. 
Issue History  
Date Modified  Username  Field  Change 
20120921 15:26  Victor Gijsbers  New Issue  
20120921 18:28  EmacsUser  Relationship added  related to 0000776 
20120921 18:37  EmacsUser  Note Added: 0001843  
20120921 18:37  EmacsUser  Status  new => confirmed 
20120921 19:43  zarf  Note Added: 0001844  
20120922 07:54  EmacsUser  Note Added: 0001845  
20120922 09:43  EmacsUser  Note Edited: 0001845  View Revisions 
20120922 09:44  EmacsUser  Relationship added  related to 0000905 
20120922 09:46  EmacsUser  Note Edited: 0001845  View Revisions 
20140112 06:14  graham  Note Added: 0002269  
20140112 06:14  graham  Status  confirmed => resolved 
20140112 06:14  graham  Resolution  open => fixed 
20140112 06:14  graham  Assigned To  => graham 
20140112 18:25  EmacsUser  Issue cloned  0001179 
20140112 18:25  EmacsUser  Relationship added  related to 0001179 
20140507 07:34  jmcgrew  Fixed in Version  => 6L02 
20140507 07:34  jmcgrew  Status  resolved => closed 
Copyright © 2000  2010 MantisBT Group 