Matching objects with snippets

This is the second time I’ve wanted to match objects with snippets, so I thought maybe I could write a little mini-extension for it. But I’m getting a weird compilation error:

[code]
Volume - Matching Snippets with Objects

The item to match is an object that varies.

Definition: A thing is matchable if it is the item to match.

To decide which object is the (O - description of objects) matching (S - a snippet):
Repeat with item running through O:
now the item to match is item;
if S matches “[any matchable thing]”:
decide on item;
decide on nothing.

Volume - Test

Exclaiming it to is an action applying to two visible things.
Report exclaiming it to: say “You say ‘[noun]’ to [the second noun].”

An exclamation is a kind of thing.
Fnord is an exclamation.

The item to match is a object that varies.
Definition: A thing is matchable if it is the item to match.

Check answering someone that:
Let item be the exclamation matching the topic understood;
If item is a thing:
instead try exclaiming item to the noun;

Test is a room. Bob is a man in Test.

Test me with “say fnord to bob”[/code]

I get:

What does that even mean?

I still don’t understand the error, but through experimentation it seems to have something to do with saying “… matches [any…]” within a to-decide phrase. If I make that test within an activity, it works:

[code]Volume - Matching Snippets with Objects

The item to match is an object that varies.

Definition: A thing is matchable if it is the item to match.
A thing can be matched.

Finding a match something is an activity on snippets.

For finding a match for a snippet (called S):
Now every thing is not matched;
Repeat with candidate running through things:
Now the item to match is candidate;
If S matches “[any matchable thing]”, now candidate is matched.

To decide which object is the (O - description of objects) that matches (S - a snippet):
Carry out the finding a match activity with S;
Repeat with item running through the list of O:
if item is matched, decide on item;
decide on nothing;

Volume - Test

Exclaiming it to is an action applying to two visible things.
Report exclaiming it to: say “You say ‘[noun]’ to [the second noun].”

An exclamation is a kind of thing.
Fnord is an exclamation.

The item to match is a object that varies.
Definition: A thing is matchable if it is the item to match.

Check answering someone that:
Let item be the exclamation that matches the topic understood;
If item is a thing:
instead try exclaiming item to the noun;

Test is a room. Bob is a man in Test.

Test me with “say fnord to bob”[/code]

I would really appreciate if someone could explain this to me.

I’ve streamlined the workaround a little, but in a way this is even more obviously a hack, and it could potentially be very slow:

[code]Volume - Matching Snippets with Objects

The item to match is an object that varies.

Definition: A thing is matchable if it is the item to match.
A thing can be matched.

Does the object match is a snippet based rulebook. The does the object match rulebook has outcomes it does (success) and it does not (failure).

Does the object match a snippet (called S):
if S matches “[any matchable thing]”, it does;
it does not.

To decide which object is the (O - description of objects) that matches (S - a snippet):
Repeat with candidate running through the list of O:
Now the item to match is candidate;
follow the does the object match rules for S;
if the outcome of the rulebook is the it does outcome, decide on candidate;
decide on nothing;

Volume - Test

Exclaiming it to is an action applying to two visible things.
Report exclaiming it to: say “You say ‘[noun]’ to [the second noun].”

An exclamation is a kind of thing.
Fnord is an exclamation.

The item to match is a object that varies.
Definition: A thing is matchable if it is the item to match.

Check answering someone that:
Let item be the exclamation that matches the topic understood;
If item is a thing:
instead try exclaiming item to the noun;

Test is a room. Bob is a man in Test.

Test me with “say fnord to bob”[/code]

I’m just gonna keep posting here until someone responds…!

I don’t even know what… Like… Is it…? So ummm… Is the answer bigger than a breadbox? Is this a multiple choice question? Does it rhyme with “spinux”? Did it strike its mother as a child? Is it brown?

I’m going to need you to be a little more specific, sir…

Okay, here’s a simple yes or no question. Is this a bug?

The following rather roundabout example compiles and other tests demonstrate that it works as expected:

[code]Does a thing match is a snippet based rulebook. The does a thing match rulebook has outcomes it does (success) and it does not (failure).

Does a thing match a snippet (called S):
if S matches “[any thing]”, it does;
it does not.

To decide whether a thing matches (S - a snippet):
follow the does a thing match rules for S;
decide on whether or not the outcome of the rulebook is the it does outcome;

Test is a room.[/code]

The following more direct and reasonable example does not compile:

[code]To decide whether a thing matches (S - a snippet):
decide on whether or not S matches “[any thing]”;

Test is a room.[/code]

Yes, it is a bug, and it has nothing to do with snippets:Test is a room. To foo (T - a topic): do nothing. To bar: foo "[any thing]". Please report it. In the meantime, you can get by with just following a rule; you don’t need all the code entailed by an activity.

Thanks for the confirmation, EmacsUser. Here’s the link:

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