tcl question: defining dynamically named variables in a namespace

René J.V. Bertin rjvbertin at
Fri Oct 7 03:47:39 PDT 2016


I have a procedure in a PortGroup that is used to define dependency variables for KF5, hiding the whole mechanism behind kf5-foo and kf5-foo-devel interchangeability from the casual port developer (and making it easy for myself too).


proc kf5.framework_dependency {name {library 0} {soversion 5}} {
    upvar #0 kf5.${name}_dep dep
    upvar #0 kf5.${name}_lib lib
# snip
        set lib                 ${kf5.lib_path}/${library}.${kf5.lib_ext}
        set dep                 path:${lib}:kf5-${name}

so that `kf5.framework_dependency libKF5Foo foo` allows me to do `depends_lib-append ${kf5.foo_dep}` afterwards (and there's another procedure hiding even that behind `kf5.depends_frameworks foo`).

I'm tidying up the variable use by the KF5 portgroup, moving as much as possible into a kf5 namespace. I haven't yet figured out how to rewrite that function above such that the kf5.*_dep and kf5.*_lib variables are moved from the global to the dedicated namespace (= become kf5::*_dep and kf5::*_lib). Is that even possible?


More information about the macports-dev mailing list