Testing whether an object supports a kind of value

I’ve created a kind of value with two possible values. I want a range of different objects to support the value (to which I’ll manually grant it), but not all.

This means there are circumstances where I need to test if an object supports that value before I read its value, to prevent getting a runtime error.

I can’t work out how to perform this test. In my test case code below, one room supports the value, the other doesn’t, but the test phrase “if the location has a splat-level” doesn’t compile. I’ll post the demo, then the error text:

splat-level is a kind of value. The splat-levels are damp, splattered.

Splatville is a room.
Dry room is east of Splatville.

Splatville has a splat-level. The splat-level of Splatville is damp.

Every turn:
	if the location has a splat-level:
		say "This room supports splat-levels.";

The compile error is:

In the sentence ‘if the location has a splat-level’ , it looks as if you intend ‘location has a splat-level’ to be a condition, but that would mean applying the possession relation (between objects) to kinds of value which do not fit - a splat-level and an object - so this must be incorrect.

I was trying to match this phrase:

if (location has a splat-level - a condition):

I recognised:

location has a splat-level = a condition

-Wade

Maybe try:

"Splat"

splat-level is a kind of value. The splat-levels are damp, splattered.

Splatville is a room.
Dry room is east of Splatville.

Splatville has a splat-level. The splat-level of Splatville is damp.

Every turn:
    if the location provides the property splat-level:
	    say "This room supports splat-levels."

It’s mentioned very briefly in WWI 13.8 The built-in verbs and their meanings.

1 Like

Hm, possibly closer. Still doesn’t compile but got me reading 4.8 in the manual as well.

The new error is " Problem. In the sentence ‘if the location provides a splat-level’ , it looks as if you intend ‘location provides a splat-level’ to be a condition, but that asks whether something provides something, and in Inform ‘to provide’ means that an object (or value) has a property attached - for instance, containers provide the property ‘carrying capacity’. Here, though, we have a splat-level rather than the name of a property."

4.8 shows a property being applied to a whole kind (food) and named (flavour). It’s by the name that the property-check test is run, but splat-level isn’t applied universally to a kind.

-Wade

It won’t compile? I copied-and-pasted it directly from my source code window after testing in 6M62.

Ah. The error message that you just posted suggests that you didn’t use the magic phrase provides the property instead of just provides. I think the difference is that provides is good for named properties, such as

A splat room is a kind of room. A splat room has a splat-level called splattiness.

...

if the location provides splattiness:
    ...

but for nameless properties, it’s provides the property.

[Example edited; in first version every room would have had a splattiness, so the test would not have been useful.]

Argh!.. you’re right. Thanks :slight_smile:

-Wade