Thread: [tcltk-perl] changes to Tcl and Tcl::Tk
Brought to you by:
hobbs
From: Jeff H. <je...@Ac...> - 2004-05-05 00:17:28
|
I implemented the changes to Tcl so that Tcl::icall now uses Tcl's unknown (AUTOLOAD) mechanism properly and kept the old version as Tcl::invoke (not directly used anywhere). I changed Tcl::Tk to not require the extra command stuff for need_tk in all cases and things still work. Seeing how small need_tk has become, I think it might be better to move this to the Tcl module as Tcl::pkg_require, and possibly take the optional args that Tcl's package require command allows (version and 'exact' boolean). Jeff |
From: Gisle A. <gi...@Ac...> - 2004-05-05 04:53:56
|
"Jeff Hobbs" <je...@Ac...> writes: > Seeing how small need_tk has become, I think it might be better > to move this to the Tcl module as Tcl::pkg_require, and > possibly take the optional args that Tcl's package require > command allows (version and 'exact' boolean). Why this wrapper at all? Why not call out to Tcl each time? I guess I'm asking "What would be the difference between these?". $tcl->call("package", "require", $pkg); $tcl->pkg_require($pkg); --Gisle |
From: Jeff H. <je...@Ac...> - 2004-05-05 05:09:57
|
Gisle Aas wrote: > "Jeff Hobbs" <je...@Ac...> writes: >>Seeing how small need_tk has become, I think it might be better >>to move this to the Tcl module as Tcl::pkg_require, and >>possibly take the optional args that Tcl's package require >>command allows (version and 'exact' boolean). > > Why this wrapper at all? Why not call out to Tcl each time? > > I guess I'm asking "What would be the difference between these?". > > $tcl->call("package", "require", $pkg); > $tcl->pkg_require($pkg); No difference actually .... need_tk was always there, and used to handle some special cases. You would say need_tk("Tree") and it would do the right thing. However, that all seems mostly irrelevant given the current structure, which is relatively transparent as well as modular. Mostly it becomes less relevant now that icall doesn't intentionally bypass Tcl's unknown (AUTOLOAD) mechanism, which meant special handling for the "require" of many widgets. The one thing it does is make sure you only do the package require call once, which of course Tcl handles as well, so you are just shaving off a bit of time there (on some widgets, that call is made each time you instantiate a widget, on others, just once for the first instantiation). Jeff |
From: Vadim K. <va...@ar...> - 2004-05-05 19:01:38
|
> Why this wrapper at all? Why not call out to Tcl each time? > > I guess I'm asking "What would be the difference between these?". > > $tcl->call("package", "require", $pkg); > $tcl->pkg_require($pkg); > It has special knowledge how to obtain something, for example, widgets that implemented with "Tix" will require Tix recursively |
From: Vadim K. <va...@ar...> - 2004-05-05 20:02:35
|
> > I guess I'm asking "What would be the difference between these?". I forgot to mention last time -- need_tk also checks for some package to be required only *once*, and this is quite important to not make same thing second time. > > $tcl->call("package", "require", $pkg); > > $tcl->pkg_require($pkg); > > > > It has special knowledge how to obtain something, for example, widgets that > implemented with "Tix" will require Tix recursively |
From: Vadim K. <va...@ar...> - 2004-05-06 22:55:43
|
Dear all, I did some web explanations: http://www.vkonovalov.ru/vtcl-usage/Using_vtcl_for_creating_Tcl-Tk_GUI_for_P erl.html and it is linked from http://perlmonks.com/index.pl?node_id=351324 I do not fully sure how to do things better, and will be extremely glad for any help from knowledgable people. If nothing will stop me, now I'll go to Tcl::Tk/tk-demos/ directory and continue cleaning things there... Best regards, Vadim. |
From: Vadim K. <va...@ar...> - 2004-05-05 19:00:37
|
> I implemented the changes to Tcl so that Tcl::icall now uses > Tcl's unknown (AUTOLOAD) mechanism properly and kept the old > version as Tcl::invoke (not directly used anywhere). And you documented this properly... Very nice. Do I understand this correctly that Tcl::invoke should be used in simple cases to improve speed? > > I changed Tcl::Tk to not require the extra command stuff for > need_tk in all cases and things still work. > > Seeing how small need_tk has become, I think it might be better > to move this to the Tcl module as Tcl::pkg_require, and > possibly take the optional args that Tcl's package require > command allows (version and 'exact' boolean). Cool. Indeed, not only "Tk" stuff could be used with that, but much more. |
From: Jeff H. <je...@Ac...> - 2004-05-05 19:04:48
|
> > I implemented the changes to Tcl so that Tcl::icall now uses Tcl's > > unknown (AUTOLOAD) mechanism properly and kept the old version as > > Tcl::invoke (not directly used anywhere). > > And you documented this properly... Very nice. > > Do I understand this correctly that Tcl::invoke should be > used in simple cases to improve speed? It would be interesting to see an icall/invoke comparison in speed if someone wanted to make it. invoke should be a smidge faster, but I wouldn't recommend it in general because of the caveats of usage - the command must exist, and you circumvent a lot of stuff like command tracing, recursion safety-checks, and the unknown mechanism. Jeff |