Next: , Up: istacks   [Index]


46.1 The common stacks API

The following syntactic bindings are exported by the library (vicare containers istacks).

Record Type: <istack>

Record type representing a stack object. The <istack> type is non–generative and available for subtyping. In this documentation <istack> instances used as arguments to functions are indicated as istack.

<istack> is an “abstract” type: it must not be instantiated directly, rather a subtype of <istack> must be defined implementing the required functions.

Constructor on <istack>: make-istack empty? top push! pop!

When we derive a type from <istack> and we specify a protocol: this is the closure object used as argument for the protocol function.

(define-record-type <istack-list>
  (parent <istack>)
  (protocol
    (lambda (make-istack)
      ---))
  ---)

Its arguments must be functions implementing the methods for the concrete stack:

empty?

A function accepting as single argument the <istack> instance itself. It must return #t if the stack is empty; otherwise it must return #f.

top

A function accepting as single argument the <istack> instance itself. It must return the top object in the <istack>.

push!

A function accepting two arguments: the <istack> instance itself and an object. It must push the object on the <istack>; it can return unspecified values.

pop!

A function accepting as single argument the <istack> instance itself. It must remove and return the top object from the <istack>.

Function: istack? obj

Return #t if obj is an instance of <istack>; otherwise return #f.

Function: istack-empty? istack

Return #t if istack is empty; otherwise return #f.

Function: istack-top istack

Return the top object in istack.

Function: istack-push! istack obj

Push obj on istack. Return unspecified values.

Function: istack-pop! istack

Remove and return the top object from istack.


Next: , Up: istacks   [Index]