On Thursday, June 2, 2016 at 7:14:19 AM UTC+2, Frank wrote:
> I am playing for the first time with ::struct::graph and realized there is no way to get the list of graphs or to test if a graph exists.
>
> [...]
>
> Then I decided that I would like to destroy all the graphs and realized there was no way to get the names either [...]
You need to rely on the implementation, which is not good practice, but it works:
proc all_graphs {} {
lmap a [interp aliases] {
if {"::struct::graph::GraphProc" eq [lindex [interp alias {} $a] 0]} {
set a
} else {
continue
}
}
}
> Shouldn't this package have a way to get all the graphs and test if they exists?
tdom has a nice way to handle auto-cleanup. Even if the package does not support it natively, you could wrap (or override) the creation of the graphs and attach a trace for variable unset (assuming that you store the name of the graph in a variable).