curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-2061] [Mantis 2098] §21.2 suggests changing the value of a variable with "let" #23

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : mattweiner

Description :

§21.2, which is discussing how it is impossible to create a variable whose value is initially set to the empty list, says:

On the other hand, writing

let M be { };

is fine provided that M already exists, and then does the obvious thing - empties M.

This is only fine if M was created as a temporary variable in the same code block. If M is a global, then you’ll run into the usual issue where Inform tries to create a separate temp variable named “M” (and in this case, it will fail because it doesn’t know what kind of value is in the list).

Steps to reproduce :

Lab is a room. 

N is a list of numbers that varies. N is {100}.

Every turn: say N.

Carry out jumping: 
    let N be a list of numbers;
    let N be { }.

Additional information :

It seems like it would probably be less misleading to change the second "let" to "now"--in general I don't think there's any reason to change the values of existing variables with "let," because "now" works for temporary variables, and using "let" for globals leads to nasty and hard-to-find bugs.

imported from: [Mantis 2098] §21.2 suggests changing the value of a variable with "let"
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-10T04:33:33+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

61eedb62875fc10070240916:

Fixed via this commit: https://github.com/ganelson/inform/commit/6d1fe47030ea0b4d370a38dfccfe310047923c1a