curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1910] [Mantis 1946] Inconsistent iterating over entire kinds #174

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : FictitiousFrode

Description :

Iterating over the entirety of a kind is stopped if you do it through an explicit list, but allowed when you go directly on the kind itself. I understand that this is one of the safety checks put in for 6M62, to stop iterating over (near) infinite lists.

I'm guessing that the reason [2] works below, is that Inform keeps a list of members of a kind, named by the plural of the kind, and you're just accessing this list instead of creating your own, but it should be consistent in what it allows.

In short, one would expect similar behavior from these two constructs, but it's different.

Steps to reproduce :

Library is a room.

When play begins:
[1] Repeat with P running through the list of persons:
        Say P;
[2] Repeat with P running through persons:
        Say P;

Additional information :

[1] above will fail to compile, but [2] will compile (and run).

imported from: [Mantis 1946] Inconsistent iterating over entire kinds
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-13T12:32:07+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
What is the error message?

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by dfremont :
This works if you "let L be the list of persons" and then "repeat with P running through L". So perhaps Inform is misparsing [1] as an attempt to iterate through all lists of people (this would explain the Problem message saying "this describes a collection of values which can't be repeated through").

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by FictitiousFrode :
Problem. You wrote 'Repeat with P running through the list of persons' : but this describes a collection of values which can't be repeated through, because the possible range is too large (or has no sensible ordering). For instance, you can 'repeat with D running through doors' because there are only a small number of doors and they can be put in order of creation. But you can't 'repeat with N running through numbers' because numbers are without end.

curiousdannii-testing commented 2 years ago

61eedb62875fc10070240916:

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

Comment by Graham Nelson:
The problem message could have been more helpful about why this misunderstanding occurred, and it now is.