El martes, 6 de febrero de 2024 a las 23:53:35 UTC+1, pd escribió:
>
> I have a problem using the package diagram. But after loading successfully the package:
>
> % lappend auto_path .
> C:/Users/... .
> % package require BWidget
> 1.9.13
> % package require diagram
> 1
>
> but I cannot use it because it doesn't find any command, for example:
>
> % ::diagram::create_diagram
> invalid command name "::diagram::create_diagram"
>
> even when the namespace exits:
>
> % namespace exists diagram
> 1
>
> What is really strange is it seems to be using a different diagram namespace because if I query for its vars and procs I get:
>
> % info vars ::diagram::*
> ::diagram::Snit_typemethodInfo ::diagram::Snit_info ::diagram::Snit_optionInfo ::diagram::Snit_methodInfo
> % info procs ::diagram::*
> ::diagram::Snit_methodreset ::diagram::Snit_destructor ::diagram::Snit_constructor ::diagram::Snit_typeconstructor ::diagram::Snit_instanceVars
>
I managed to solve the problem, apparently the package was loaded right but it's an illusion, really the package that was loaded with
% package require diagram
is the tcllib diagram package which happens to be also version 1.0 and also defines a diagram namespace, for this reason all procs and vars in the namespace are so strange, they are from tcllib diagram rather than diagram.tcl
I solved it making the diagram.tcl a module (pm) rather than a package, so I can better control which one is loading.
This issue makes me to realize about the problem of name collision between packages, I think it should be managed but don't know how because there's no proper mechanism , maybe a hierarchy name similar to java packages.
Also I have another problem with tcllib package (I've played with it after this problem) but I'll discuss it in another post.