AP/STklos, version 1.2: visitors and object graph traversal. Files in this directory: ap.stk -- load this file to get all the pieces: (require "ap") path.stk -- path directives. edge.stk -- edges in the object graph. visitor.stk -- visitors. print.stk -- a generic print visitor. pretty-print.stk -- a generic visitor for printing with indentation. company.stk -- the Company/Employee example. Defining a class: ::= "(define-class" "(" { } ")" "(" { } ")" ")" where is any valid STklos identifier; is an expression which evaluates to a class; is any valid STklos slot description. Instantiating an object: ::= "(make" { } ")" where is the name of a class which has previously been defined; is one of the initialization keywords for a slot of the class; is a STklos expression which is used to initialize the slot whose initialization keyword is . Defining a path directive: ::= "(define-path" { } ")" where is any valid STklos identifier; ::= ":from" | ":to" | ":bypassing" where is an expression which evaluates to a class object; ::= "(" { [ | ] } ")" where is an expression which evaluates to the name of a slot defined on a class. Visitors: [define-visitor documentation still needed] The traverse function takes a path directive, an object, and 0 or more visitor classes or objects. It traverses the object graph rooted at the object, visiting each visitor at each object and edge. Object traversal has three steps: 1. call the before method on each visitor for the current object, in the order they are specified in the traversal argument list. 2. if the directive does not specify the class of the current object as a target class, call traverse-edge on each edge from the current object. 3. call the after method on each visitor for the current object, in reverse order. Edge traversal similarly has three steps: 1. call the before method on each visitor for the current object and edge, in the order they are specified in the traversal argument list. 2. if the directive does not specify the class of the current object as a bypass class, or the name of the current edge as a bypass edge, call traverse on the target of the current edge. 3. call the after method on each visitor for the current object and edge, in reverse order.