On 01/06/2012 20:54, Thomas MENEZ wrote:
> As I said earlier in this thread, I am trying out tcloo these days...
Well, it does do concealment of methods (defaulting to "only make a
method public if it starts with a lower-case letter") but isn't very
serious about it. It also turns out to be very useful to not be super-
strict with enforcement, as that makes doing callbacks of various sorts
much easier. ("Concealment" is probably the best word for what is going
on, as non-public methods are just not advertised.)
Another scheme you could use for public/private methods is to put the
private methods in a separate namespace and use [namespace path] to make
them visible when *in* the public namespace, but not *via* it. That
sounds very complicated, but isn't. (The downside is that the two don't
share where they keep their variables; [namespace upvar] helps.)
namespace eval toto {
proc tutu { a b } {
_tutu $a $b
}
namespace export *
namespace eval private {
namespace import ::toto::*
proc _tutu { a b } {
puts "called with a=$a b=$b!"
}
}
namespace path ::toto::private
}
toto::tutu 1 2 ;# works
toto::_tutu 3 4 ;# error, no such command
Tcl's *real* mechanism for making things shrouded is by partitioning
between interpreters and using aliased and hidden commands to link
between. I suspect you're working too hard though. :-)
Donal.