Confused with §17.16 of Writing with Inform

(§17.16. Understanding things by their relations)

In Writing with Inform, example Cinco (319) says:

Understand "[something related by containment] taco" as the taco.

Question 1: how does Inform know to what container that “something” is related? Is it the taco because the sentence ends with “… as the taco.”? “Something related by containment” could mean related to any thing, not specifically the taco.

Question 2: In that case, can we not generalise such a rule for any container? I tried:

Understand "[something related by containment] [container]" as the container.

… and had problems when I introduced a second container (a box):

… which means that the “understand” phrase does not keep the same container throughout. Perhaps if we could apply some sort of “a container (called the case)…” clause, things would work out, but I don’t know how to do this in an “Understand…” rule.

Question 3: How come “related by containment” means only the content? I tried:

… thus, when the place of [something related by containment] is taken by “taco” (the box’s content), the “understanding” works; when it is taken by “box” (the taco’s container), it does not.

I am not saying that containment is a reciprocal relation (which obviously is not), but I don’t see how “related by containment” means specifically the content side of the relation.

The token [something related by XXX] matches the text “foo” with the object bar if “foo” matches an object which is related to bar by the XXX relation. That’s just the way that Inform defines the token (and that explains the asymmetry, if the relation XXX is asymmetrical, like containment).

So in

Understand "[something related by containment] taco" as the taco.

we only get matches for things contained in the taco, because the taco is the only object being “understood” in this rule.

On the other hand, in

Understand "[something related by containment]" as a container.

all containers are relevant, and the effect is that if the beef is in the taco then Inform will understand “beef” as referring to the taco.

The code

Understand "[something related by containment] [container]" as a container.

causes problems, because Inform does not assume that the container being matched by “[container]” has to be the same as the object being understood. So if the beef is in the taco then “beef dustbin” will be understood as the taco.

This code will do what I think you are trying to do. (But someone will probably come up with a more natural solution.)

Identity relates a thing (called X) to a thing (called Y) when X is Y.
Understand "[something related by containment] [something related by identity]" as a container.

(NB Inform actually has an built-in equality relation, but it doesn’t allow it to be used in tokens like this.)

Thank you.

So, “[something related by containment]” means “something that is contained” and not “something that contains.” I’ll have to remember that…