Two questions about the empty table as a property

I decided to use properties more heavily, and in one case, I had code as so:

a room has a table name called actions-table.

r1 is a room.

r2 is a room. actions-table of r2 is table of r2 actions.

table of r2 thinks
temperature  happened  text
30   false    "It's hot in here."

The basic idea is that if a temperature is above a certain level, a random activity happens, if any is left. Then the “happened” column is marked false.

Now what I am wondering is, does the code

repeat running through actions-table of location of player:
    (etc.)

have any chance of going wrong if the table is empty? I mean, it doesn’t seem like it should, but a search of the docs turned up nothing.

Also, how would we check for “if actions-table of location of player is the empty table?” It doesn’t seem to work in 6g60.

Thanks!

You can check “if [table] is empty”. But repeating through an empty table is safe, it just won’t do anything.

3 Likes

Oh, man. I feel a bit silly about not trying that, since I also had indexed text as the property for a room and wrote the code if certain-text is empty, say "[default-text]";

Thanks again!

yeah, there isn’t a table that is the empty table, (the empty table) is just what Inform outputs when you try to say a table name that’s null. (There are a handful of exceptions to the variables/properties always default to some non-null value thing.)

2 Likes

I had a similar question and thought I’d add to this thread.

Is there a way to set a table name to this null value to programmatically blank out such a property? You can’t set that property (the actions-table in the example above) to nothing or empty or the empty table. Is this one of those cases where we need to define our own “Table of Null” if we need one?

Maybe something like

To decide which table name is The Empty Table:
	(- TheEmptyTable -).

will do the trick?

Something that ends up in most of my programs is the Ultimate Nullifier:

To decide what K is a/-- null (name of kind of value K): (- 0 -).

then

table-var is initially the Table of Locale Priorities.
when play begins: now table-var is the null table name.

Edited: oops, I was wrong above. There is a difference between the empty table and the null table. This is how you create a table saying whose table name will output (the empty table):

The empty-table is a table name that varies.

If you try to say the table name of a null table, you get

** No such table **

I don’t know what the internal representation of this empty table is.

Even more ultimate set of nullifiers:

The-empty-table is a table name that varies.
To decide what K is a/-- null (name of kind of value K): (- 0 -).
To decide what K is a/-- null text: decide on "".
To decide what K is a/-- null table name: decide on the-empty-table.
1 Like

It comes from Definitions.i6t. Or Definitions.whatever the extension is now.

Empty Table. Similarly: the default value for the “table” kind of value, a Table containing no rows and no columns.

Array TheEmptyTable --> 0 0;
2 Likes

“** No such table **” is what you get when you pass an invalid value, including 0, to PrintTableName().

But doing anything else with an invalid value is likely to cause errors. For example, this crashes the interpreter:

To decide what K is a/-- null (name of kind of value K): (- 0 -).

When play begins:
	let foo be a null table name;
	showme the contents of foo;

Better to stick with the empty table for a typed null value.

3 Likes