0

Is there a way to obtain a friendship between classes in incr Tcl?

Consider the code below.

package require Itcl

::itcl::class A {
   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?

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
Vahagn
  • 4,670
  • 9
  • 43
  • 72

1 Answers1

0

Itcl doesn't provide friends.

You can hack around this by constructing a call using namespace inscope, like so:

namespace inscope A {A::f}
Trey Jackson
  • 73,529
  • 11
  • 197
  • 229