[I6] Does referencing objects with a multi word name need parse_name()?

If an object has a multi word name that a player might reasonably type (i.e. ticket machine) but the words you wish to refer to it are ‘machine’ and ‘ticket machine’ but not ‘ticket’ (because you may be holding that) do I really have to use parse_name() in Inform 6? All the examples I see seem to suggest it does, but it’s such a basic function and even Inform 6 already handles more complex things by default.

I know Inform 7 handles this, but I don’t get on with its natural language style, and I’m trying to use PunyInform which needs Inform 6 (however, the name interpretation appears to work the same between the puny library and the inform 6 library).

Have I missed something?

1 Like

Yes.

In I6, parse_name is a basic function.

(This is a somewhat flip answer, but that was really the approach Inform took before I7. parse_name is a typical piece of “here’s the tool, you can do the work” I6 architecture. I’m sad that I7 doesn’t have any direct equivalent.)

I suppose this falls under “indirect”, but it does have equivalents for most such usage. Most names just work, without fanfare. “Does the player mean” rules can resolve ambiguity (so that it won’t recognise “ticket” as the machine if the actual ticket is also in scope), and you can have conditional names (“Understand … when …”) and property-based names (“Understand the broken property as describing a container.”). And if all else fails, you can express it in the form of an I6 GPR.

I7 has equivalents for the most common usages of parse_name. There’s no way to apply general logic to accept/reject a string of words as an object name.

(A GPR is a grammar token – it only applies to a specific grammar line, not to recognizing the object in all contexts.)

(I came up with the hack of writing an I6 routine and assigning it to the object’s parse_name property at runtime. I never got around to testing it, though, since I never truly needed it. But I’ve come close.)

Can’t you Understand "[my custom GPR]" as the widget.?

I don’t think so? But maybe. Let me give it a shot.

(That would be a topic recognizer rather than a GPR per se, which is why I was confused.)

Yes, you’re quite right – 27.23 describes this and I just never connected the dots.

And they are GPR routines after all. :)

Thanks!

1 Like

There are a few Inform 6 extensions that allow to declare words as “optional” or “adjectives” (as in, they are counted only if there’s a real noun with them). Try Neil Cerutti’s pname.h, or my own PhraseNames.h (https://bitbucket.org/hlabrand/extensions-i6/raw/a0220eca8ba9fc0ba2e1f358bfad291c322c2173/PhraseNames.h). Its not perfect but it saved me from writing boring complex parse_names more than once. (I havent tried it with Puny but I cant think of a reason why it wouldnt be compatible.)

And if you need a parse_name routine, this should do the trick:

  parse_name
  [ nw;
    nw = NextWord();
    if (nw == 'ticket')
    {
      nw = NextWord();
      if (nw == 'machine')
        return 2;
      return 0;
    }
    if (nw == 'machine')
      return 1;
    return 0;
  ],

The ticket can be defined as usual.