Hi Tcl.pm etc developers,
I need some advice.
In my everyday programming, I often use a subroutine that helps me to bind a
number of tcl subs with perl by call to CreateCommand, namely this part of code:
sub Tcl::Tk::bind_ptcl {
my $int = shift;
no strict 'refs';
for my $subname (keys %::ptcl::) {
$int->CreateCommand("ptcl_$subname",\&{"ptcl::$subname"});
}
}
this allows me to create a number of subroutines in Perl in ptcl:: namespace
that are automatically get binded to Tcl/tk all at once
sub ptcl::sub1 {
print "hi, I am sub1!\n";
}
and then write in pure-tcl GUI code
$interp->Eval <<'EOS';
button .b -text {button 1} -command ptcl_sub1
EOS
or, if pure-Tcl is not preferable, the old way:
$frame->Button(-text=>'button1', -command=>'ptcl_sub1');
so this works well (actually I have same approach for binding variable names)
I wonder, is it reasonable for this approach to be "standartized" and included
to, say, Tcl.pm module?
Maybe with a slightly different interface.
For example - all Tcl names from some predefined Tcl namespace could be bound
to perl subroutines all at once.
I find this very helpful.
Thanks in advance for your ideas,
Vadim.