Is there a way to make [incr Tcl] classes friends?
Is there a way to obtain a friendship between classes in incr Tcl?
Consider the code below.
package require Itcl
::itcl::class A {
开发者_JAVA百科 private {
proc f { } {
puts "==== A::f"
}
}
}
::itcl::class B {
public {
proc g { } {
puts "==== want to be able to call A::f"
}
}
}
I want A::f
to be invisible outside A
bur functions of B
. How can I achieve this?
Itcl doesn't provide friends.
You can hack around this by constructing a call using namespace inscope
, like so:
namespace inscope A {A::f}
精彩评论