1
\$\begingroup\$

By no small amount of pain, I have discovered that the following Inform 6 source doesn't work as expected: instead of calling the right branch of Bar.after based on the current action, it always prints Called from Foo:

Global action;

[ R_Process a;
    action = a;
    indirect(#actions_table-->a);
];

Verb 'foo' * -> Foo;
Verb 'baz' * -> Baz;

Object Bar "bar"
  with after [;
    Foo: "Called from Foo";
    Baz: "Called from Baz";
    ];

[ BazSub;
    print "[Baz]^";
    Bar.after();
];

[ FooSub;
    print "[Foo]^";
    Bar.after();
];

[ Main;
  <foo>;
  <baz>;
];

Running it produces the following output:

[Foo]
Called from Foo
[Baz]
Called from Foo

However, if I prepend the following three lines to the Inform script above, then it works as expected:

Constant LibSerial "foo";
Global reason_code;
Property additive life;

Now the output becomes:

[Foo]
Called from Foo
[Baz]
Called from Baz

The three lines are all important:

  • Omitting the definition of the LibSerial constant (i.e. keeping the other two lines only) causes Called from Foo to be printed from both callbacks.

  • Omitting the declaration of the (as far as I can see, unused) variable reason_code gives the following compile-time error:

    "<constructing output>", line -65535: 
    Error:  No such constant as "reason_code"
    
  • Omitting the declaration of the life property causes a similar compile-time error:

    "<constructing output>", line -65535: 
    Error:  No such constant as "life"
    

So basically my question is, what is going on here? What is the effect of defining LibSerial and why does it need the life property and the reason_code global variable to be declared?

\$\endgroup\$

0

You must log in to answer this question.

Browse other questions tagged .