[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: VTP path questions
In article <26702@sophia.inria.fr>, Guido.Bosch@loria.fr (Guido Bosch) writes:
|> Now here are yet some other questions concerning paths:
|>
|> 1. Why are there so many different kinds of paths? Especially I
|> couldnt figure out what "started paths" are usful for.
Part (or most) of your confusion stems from a significant error
on my part. I recently noticed that several pages of the path
manual seem to have "disappeared" during the production of version 1.2.
These pages discuss path syntax, and without them, it is difficult to
understand functions that construct paths. I have corrected the
documentation error and a new postscript version is available.
|> 2. Can I transform one path type into an other one, e.g., to make
|> changes on a tree denoted by a selection path, or should I better
|> leave this job to higher-level functions, such as
|> {variable}:change, {variable}:delete and so?
The manual doesn't indicate that much is possible for creating
a modification path from a selection path. One reason for this
might be that a selection path can refer to nested subtrees and
the semantics of modifications in this case is not clear
(for example, trying to delete below an already deleted subtree).
On the other hand, you may use the {path}:follow-all-leaf function
(described on page 6 of the manual) to modify a tree directly while
following a path. N.B. The manual says that the <function> required
by {path}:follow-all-leaf must return "the subpath for the next iteration"
otherwise {path}:follow-all-leaf goes into an infinite loop.
For example, in article 153, I defined a function that uses
{path}:follow-all-leaf:
(de {path}:set-tree-pointers (path root)
({path}:follow-all-leaf path root 0
(lambda (leaf-path type subtree)
({leaf}:val ({list-started}:started leaf-path) subtree)
;;Return the continuation point:
({list-started}:list leaf-path)
)
)
path
)
The {list-started}:list function returns the "cdr" of the leaf-path,
which is how we wish to continue the traversal.
This method's drawback is that tree modifications occur outside of the
variable structure.
|> The problem is even more general: I have a lot of trouble to
|> distinguish in the doc `VTP internal' functions from `programmer
|> level' functions. I guess that most of the functions of the
|> {variable} and {tree} packages belong to the second category, but
|> I'm seriously troubled for the rest. Some general advice would be
|> very helpful here.
The only advice I can think of is: When possible, try to manipulate
trees within a variable structure since the variable automatically
manages modification paths and updates "selections"
(which are named paths).
If you have more specific questions, let me know.
Ian