I created this :
# file1.tcl
namespace eval myNS {
namespace ensemble create -command ::make
namespace export cmd1 cmd2 cmd3
}
I've just realised that if I add another procedure cmd4 to my export namespace in another file like this:
# file2.tcl
namespace eval myNS {
namespace export cmd4
}
I can also write like this make cmd4 $args
My question is: Is it possible to limit it to cmd1 cmd2 cmd3 commands?
You can use the
-subcommandsoption when creating the ensemble to restrict what's available instead of the default of all exported commands:After loading both files,
make cmd4will give an error, butmyNS::cmd4can still be imported withnamespace importor called directly; just not through the ensemble.