Questions regarding the following code. I have commented out code that throws compilation errors:
Lab is a room.
An animal can be tamed or untamed. An animal is usually tamed.
The dog is an animal in the lab.
The bird is an untamed animal in the lab.
The bird can be flying or grounded. [The bird is usually flying.]
The bird is flying.
[The dog is not flying.]
(1) I understand that animal is a kind (similar to a class in OOP) but what is the bird and the dog called (similar to object or instances of class in OOP) Objects? Kind instances?
(2) I understand that tamed/untamed is a boolean property of the animal kind. But what is flying/grounded? It seems to be a property associated with bird only, which is an instance of the animal kind?
(3) It seems like properties associated with kinds are good for general solutions and properties associated with instances of kinds are good for instance-specific solutions. Is this good design or should I always be defining the properties at the kind-level?
I donât know if youâd call them âbooleansâ, I think Inform would refer to it as a âconditionâ or âvalueâ. I think saying âthe [something] can be red or blueâ or âthe [something] is either red or blueâ is a shortcut to make a âvalue that variesâ.
Either way. If you want the value to associate with all instances of a kind do it at the kind level. If you have a single thing or a specific instance of a kind that is âalways blueâ that can override your default value if it also is defined at the kind level. In a list of values, if you donât specify, it will default to the first in the list.
(Inform 7 always assumes that if you make a specific rule or declaration for an instanced item that the specific rule will take precedence over any default rule or condition or behavior the item would otherwise follow.)
The most general name for them is âobject.â âObjectâ is a kind that is at the top of this particular hierarchy; I think it goes âobjectâ->âthingâ->âpersonâ->âanimalâ in this case. That is, a thing is a kind of object, a person is a kind of thing, and an animal is a kind of person.
I believe that technically these all are considered values, and there are other kinds of values too. I donât find thinking of things that way very illuminating, but it might be different from your programming background! Writing with Inform §4.1 and §22.1 both contain more information about kinds.
For a lot of information on how Inform has parsed these sorts of things, have a look at the Kinds tab in the Index. You can see the tree of what kinds inherit from other kinds there, and what properties they have.
IIRC both An animal can be tamed or untamed and The bird can be flying or grounded are defining a new kind of value, just like A color is a kind of value does â but in the latter case youâre giving it a name you can refer to later (and assign to other things, such as other kinds or objects or variables) and in the former two cases youâre not â which is more succinct, but makes them harder to re-use elsewhere.
The first one declares a property on a kind of thing (and thus on all instances of that kind), and so you declare its default value with âis usuallyâ so that it can be overridden later by a specific instance. Meanwhile the second one declares a property on a specific thing, so Inform requires you to be more direct about stating its value, as it canât possibly be overridden.
Although these unnamed properties can still be referred to in some contexts; eg. you can Understand the flying property as describing the bird. and now the player can refer to the âflying birdâ or the âgrounded birdâ and it will know what you mean. (Although you probably wouldnât want to actually do that â this sort of thing is most useful for properties applied to collections of things, to aid in disambiguation, so is less useful applied to a single object. Having said that, I do have a case where a single specific animal in a story Iâm working on can be changed from âwildâ to âtameâ and back, and its printed name changes to reflect this, and so does its Understanding.)
So just an FYI on this. I was looking at the automated documentation on an extension and it appears to call the instantiation of a kind a âphysical creationâ. Donât know if that is in the common vernacular, but thatâs what Inform 7 calls it.
Good point. I did think of that and couldnât find the string in any of the extension authorâs code that matched it.
I ran a quick test of my own just to make sure. Hereâs my test extension that has nothing more than a kind and an instantiation of the kind:
Version 1 of Test Extension by Lance Campbell begins here.
"Test Extension Description"
A foo is a kind of object. The bar is a foo.
Test Extension ends here.
---- DOCUMENTATION ----
Test documentation.
Hereâs the results displayed in Inform 7:
So, itâs a bit of a mouthful, but thatâs what the IDE says it is called.