Specialization by inheritance

\dlpindex{specialization} An object may specialize another object by inheriting its code, and adding some specific functionality. We may now define a semaphore, as respectively a specialization of a number and a counter, by declaring \lprog{semaphore}{ .ds semaphore.pl } Hence a semaphore is a kind of counter, which itself is a kind of number. In this, somewhat artificial example, the only active object is a semaphore, active in the sense that it contains a constructor clause. The non-logical variable n is inherited from the object number, via the object counter which provides the methods for incrementing or decrementing n. Conceptually, when creating an instance of semaphore, an object is created that contains n as a local non-logical variable and as clauses all clauses occurring in the objects involved. As a consequence, when calling the constructor for semaphore, the non-logical variable of the newly created object is assigned a value by the call to put.