开发者

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}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜