Old programmer blues

I realized recently that this trick to include invocation of arbitrary phrases in adaptive text along with the item described providing an equivalent to self pretty directly creates traditional methods… albeit with the substantial limitations that they can’t take parameters or return a value other than text.

Lab is a room.

To say @ (ph - phrase): (- if (0==0) {ph} -).

An object has a text called the method.

Alice is a person in the lab.

The method of Alice is "[@ try the item described jumping]".

when play begins: say the method of Alice.

And there’s also my even more tortuous former effort at OOP.

But the thing that exercise made me realize is that I7 offers the equivalent via rulebooks; it’s just inside-out (and somewhat verbose).

Let’s take a traditional OOP-y thing: you have a class with an attribute with an associated reader for that attribute. But then you want a subclass whose method overrides the parent class method and does something dynamic instead of just returning the attribute.

Uninspired example:

[ just syntactic sugar for `<K> produced by the X rules for Y` ]
To decide what K is a/-- result of/-- a/an/-- (r - an M based rulebook producing values of kind K) on/of/for/with a/an/-- (v - a value of kind M):
  (- ResultOfRule({r}, {v}, true, {-strong-kind:K}) -).

A thing has a number called the @temperature.
The @temperature of a thing is usually 10.
A hot-thing is a kind of thing.

Thermometer is a thing based rulebook producing a number.

Thermometer for hot-thing (called the hottie):
  rule succeeds with result 100 * @temperature of the hottie.

Last thermometer something (called the thermometee):
  rule succeeds with result @temperature of the thermometee.

To decide what number is the temperature of (t - a thing):
  decide on the result of thermometer for t.

The microsun is a hot-thing.

when play begins:
  say "[temperature of player].";
  say "[temperature of microsun].";
1 Like