Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue L61032

IndirectlyContains() fails with dynamic objects
Submitted by: Roger Firth     Appeared in: Library 6/10 or before     Fixed in: Library 6/11
Problem

When you specify a Class which supports creation of objects at run-time, the compiler actually pre-allocates the objects -- including one spare to support recreate() -- as children of the Class itself. This parentage leads to problems with IndirectlyContains(). For example, this code:

  Class   Thing(3);
  ...
  objectloop (x ofclass Thing && IndirectlyContains(location,x))
      print (name) x, "^";

causes this run-time error:

  [** Programming error: tried to find the "parent" of Thing **]
  [** Programming error: tried to find the "parent" of Thing **]
  [** Programming error: tried to find the "parent" of Thing **]
  [** Programming error: tried to find the "parent" of Thing **]
Solution

This is the coding of IndirectlyContains:

  [ IndirectlyContains o1 o2;
    while (o2~=0)
    {   if (o1==o2) rtrue;
        o2=parent(o2);
    }
    rfalse;
  ];

and the fix adds an additional test:

  [ IndirectlyContains o1 o2;
    while (o2~=0)
    {   if (o1==o2) rtrue; if(o2 ofclass Class) rfalse;
        o2=parent(o2);
    }
    rfalse;
  ];

An alternative (and arguably better) solution would be to fix objectloop so that it omits the pre-allocated objects (which, after all, don't yet exist in any real sense). A game which really did want to loop through them could use something like:

  objectloop (x in Thing) ...


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.