Keeping Thing descriptions in Tables?

I thought of trying out tables to organise the description of things in rooms, somehow like this:

Table - thing descriptions
thing           description
my-thing1       "This is a very nice thing"
my-thing2       "This is very nice, too"

Maybe I overdo something here, but I see it as a way to learn more about functions and tables.

Instead of directly accessing the table, I wanted to use a function, something like this:

To decide what text is a thing-description for (present-thing - a thing) of (T - a table name):
	Let my-description be the description corresponding to the present-thing in the table T;
	Decide my-description.

Well, that function already does not compile (something in the body is wrong). I tried to simplify it to see if I could use such a function in the end at all:

table-test is a thing in the kitchen. The description of table test is thing-description for table-test in appartment descriptions.

But I7 doesn’t seem to like that.

This is an experiment to understand tables and functions - is there a way to make this compile?

1 Like

Yes. You had several small mistakes. This compiles:

Table of thing descriptions
thing	description
my-thing1	"This is a very nice thing"
my-thing2	"This is very nice, too"

To decide what text is thing-description for (O - a thing) of (T - a table name):
	Let D be the description corresponding to a thing of O in T;
	Decide on D.

The description of my-thing1 is "[thing-description for my-thing1 of table of thing descriptions]."
The description of my-thing2 is "[thing-description for my-thing2 of table of thing descriptions]."

(I used one-letter variables because it makes the example easier to read. Variable names like present-thing are fine, just unwieldy sometimes.)

You could avoid the boilerplate by writing an examining rule:

First carry out examining:
	if there is a description corresponding to a thing of the noun in table of thing descriptions:
		let D be the description corresponding to a thing of the noun in table of thing descriptions;
		say "[D].";
		stop;
	
2 Likes

Thank you for the prompt reply!

Using a text description in the table like „[if ]say a[otherwise]say b[end if]“ will not work that way, right? Maybe then not so clever then to keep these descriptions in a table.

You can put substitutions like that in any text. Try it.

There are a couple of hassles that the table gets into. For example, if you want an object description to end with a question mark or exclamation mark, everything gets messy. (You can make it work, but you’re in line break hell.)

Tables are also marginally slower than the usual way of doing things. This probably won’t matter except in a very large game.

It’s also just not all that much tidier than the usual way of doing things! If you weren’t using the table, you’d write

The description of my-thing1 is "This is a very nice thing."
The description of my-thing2 is "This is very nice, too."

This is more or less a tabular layout already, visually speaking.