Complicated description with multiple relations.

I can’t get this description of objects to work. I think there may be some kind of operator-precedence problem, but I can’t figure out how to debug it. Should I give up and write a loop?

[code]Cohesion relates a thing (called the first item) to a thing (called the second item) when the first item is the second item or the first item incorporates the second item or the second item incorporates the first item.

The verb to be stuck with implies the cohesion relation.

Connection relates various things to various things.

The verb to connect to (he connects to, they connect to, he connected to, it is connected to, he is connecting to) implies the connection relation.

test is a room.

The rope is a thing.

The chain is a thing.

The chain connects to the rope.

When play begins: say “Long version: [the list of things stuck with the chain that connect to something stuck with the rope]. Short version: [the list of things stuck with the chain that connect to the rope].”[/code]

The output is “Long version: the rope. Short version: the chain.” I would expect both versions to give the chain. Why don’t they?

Seems to me that in “the list of things stuck with the chain that connect to something stuck with the rope,” “that connect to…” is being taken to modify “chain” rather than “things stuck with the chain.” --Or something like that. Anyway, this seems to work:

When play begins: say "Long version: [the list of (things stuck with the chain) that connect to something stuck with the rope]. Short version: [the list of (things stuck with the chain) that connect to the rope]."

UPDATE: This is probably one for bukayeva’s gotcha list.

1 Like

This does not immediately answer your question, but you can always avoid writing a loop in these cases, by instead writing a definition or to-decide-whether phrase that sums up your desired property in a single term.

That’s exactly what I’m trying to do - this code is going into a to-decide-which phrase so I don’t have to fuss with it anymore.

I’m going crazy trying to figure out how it’s being parsed, though. All the alternate parsings that I can see would resolve to nothing, not the rope. Can anyone tell me what’s actually going on?

If you look at the generated I6 for such expressions, it will contain a call to a Prop_* routine, which will explain the parsing in its comments. In this case, for Prop_0, your long version is parsed as asking forthe list of x such that for some y: x is a thing x is stuck with y * the chain is connected to y y is a thing y is stuck with the rope
So Matt is right about that connect to something stuck with the rope'' applying to the chain (Inform doesn't realize that the chain, being singular, should useconnects’’ rather than connect''). But also, on the starred line, the firststuck with’’ is being interpreted as relating the thing being considered for the list and the ``something’’ between the chain and the rope. This looks like a bug; please report it.

Okay, but I’m still so confused that my report might be a little hard to understand…

inform7.com/mantis/view.php?id=632

Looks good to me. I have added another test case to try to show how Inform is misreading such conditions.

Man, I don’t know how you can get your head around this! So this:

There is a room. When play begins: showme the list of things enclosing the player that encloses something; showme the list of things that enclose something enclosed by the player.

…should match the player in the second case, but not in the first case, right?

Sure, as long as you add a line like The player carries a box.

There is a room. When play begins: showme the list of things enclosing the player that encloses something; showme the list of things that enclose something enclosed by the player.

So, “that” is a low-precedence operator, then? Lower than “something” next to “ed / ing” I mean.