The following functions access the value of a path within a total FD.
(top-gdp fd path)
|
Top-gdp - short for go-down-path - follows a path within a total FD and returns the FD pointed to by the path. It is guaranteed to return a proper FD, that is, it will never return a path to another location, but instead, it will follow indirections until a proper FD is found.
Top-gdpp is a companion function which instead of returning the FD pointed to by the path returns the pair containing the appropriate value. As for top-gdp, this function always follows indirections and returns a pair whose second element is a proper FD and never a path.
If requested the value of a feature which is not present (not yet instantiated) in the total FD, top-gdp (or top-gdpp) will construct the path up to the requested level as shown in the example with the request for the value f the path {x y} which adds the path (x ((y nil))) into the total fd. This is the manifestation of the fact that the value nil adds no information to an FD. The path (x ((y nil))) does not change the meaning of the FD since it adds no instantiation.
The function filter-nils is used to remove these useless empty fds from an fd, and return only the useful information stored in an FD.
(filter-nils '((a nil) (b ((c 1) (d nil))) (x ((y nil)))))
->
((b ((c 1))))
|
If the path requested is not compatible with the grammar, the value none is returned. This can happen in 2 cases: when the requested path extends below a leaf of the FD (for example the path {a a1} above) or when the requested path does not satisfy an FSET declarations (for example the path {b b3} above).
Top-gdpp can either return a pair from the total FD or none. When the result is a pair, it is possible to perform a (setf (second pair) new-value) and the total FD will be appropriately modified - as long as the new value is a valid FD. This is one way to ``patch'' a total FD with new values.