of - get the slot value of a frame
slot of frame
slot of frame retrieves the value of slot from frame. If the value is not present in the instance frame then the inherited value is obtained. If there is no inherited value, the call fails.
Of is a 2-arity function that returns a value in an is expression.
cylinder ako object with height: range number(new value) and new value > 0 help print("Height must be a positive number") if_needed ask if_removed remove volume from this cylinder cache yes; radius: range number(new value) and new value > 0 help print("Radius must be a positive number") if_needed ask if_removed remove cross_section from this cylinder cache yes; cross_section: if_needed pi * radius of this cylinder ** 2 if_removed remove volume from this cylinder cache yes; volume: if_needed cross_section of this cylinder * height of this cylinder cache yes!
c isa cylinder with height:2; radius: 4! : height of c? 2 : volume of c? 100.531 colour of c? ** no
When the value of volume is requested, iProlog first searches the instance frame c for a slot named volume. When this is not found it checks c's isa slot and looks for volume in the generic cylinder frame. When found, the if_needed dæmon is triggered.
Slot values are stored in Prolog's database. For example, the contents of the database just after c has been initialised include the following clauses.
value(c, isa, [cylinder]). value(c, height, 2). value(c, radius, 4).