I don't think optimization for the -command option is so important,
because the command is called when the user presses a button,
not from within a loop or some time critical operation.

I see more an issue with global variables. If you write a handler
for a -command and you set variables, they will be global and
pollute the global namespace. It is very difficult to keep track
of global variables, worse if you have a trace that triggers some
weird side effect when the variable is set. (OK, ok, Visual Tcl
still has a bunch of global variables, but this will be improved :-)

CG

"Techentin, Robert W." wrote:

> > -----Original Message-----
> > From: Stef Pillaert [mailto:[EMAIL PROTECTED]]
> >
> > It is a solution (and I realise that in a lot of Tcl/Tk
> > tutorials this way of coding is recommended ;-), but I
> > hesitate to write proc's for every button, where the
> > actual command is very simple and short : in those
> > cases I prefer to keep it in the button-command itself.
> > I even have to admit that I often have very long and
> > complex button-commands (Why would I write  a procedure
> > for it, since I'm not going to use it elsewhere, and
> > Vtcl shows me the command nice and clean in one window,
> > the same as if it where a procedure).
>
> The reason that you should write procs is that the button's -command script
> cannot be byte-compiled.  You may only call the command script from one
> place, but it will run faster if you use a proc.
>
> Tk must dynamically build the command string to include any % substitutions
> (see the [bind] man page), eliminating the possibility of byte-compiling.
> Disclaimer:  I don't recall if command scripts that without % substitutions
> get byte-compiled.  A little experimenting on my part indicates that they do
> not, but there is probably a more authoritative source.
>
> Bob
> --
> Bob Techentin                        [EMAIL PROTECTED]
> Mayo Foundation                                 (507) 538-5495
> 200 First St. SW                            FAX (507) 284-9171
> Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/
>
> _______________________________________________
> vtcl-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/vtcl-user


_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/vtcl-user

Reply via email to