Re: Tcl the misunderstood



Wojciech Kocjan wrote:
On Tue, 07 Mar 2006 16:36:08 +0100, Salvatore Sanfilippo
<antirez@xxxxxxxxx> wrote:

Hello all!

At http://antirez.com/articoli/tclmisunderstood.html you can find
an article I wrote in order to promote Tcl, I posted it on reddit.com
and I'll be glad if you like the article if you can help voting the
entry.
Also any comment is very welcomed.

Reddit.com is a news site with a strong number of programmers
among the users. So it sounds like the good place to promote a
bit Tcl.

Great work, I see you attracted some attention by comments, and probably
more people read it but didn't comment.

Anyway, I definitely lacked "trace" examples, maybe even combined with Tk
entry widgets. Say:

entry .text -textvariable ::text
label .lower -textvariable ::textLower
label .upper -textvariable ::textUpper
proc doConvert {args} {
set ::textLower [string tolower $::text]
set ::textUpper [string toupper $::text]
}
pack .text .lower .upper -fill x
trace add variable ::text write doConvert

...and try implementing the same in any other language in less than 10
lines :-)


Yeah, 'trace' is one of the more under-appreciated commands in Tcl much
like 'after'. A few years back you have lots of people not
understanding the power of the 'after' command. On the wiki, you can
even read some old comments showing that some people consider the
'after' command a bug in the language. Now that there are lots of
example of animation in Tcl/Tk in the wiki and other places the event
queueing paradigm with 'after' is a lot more established and most
people seem to understand it pretty quickly.

But there are not many examples on the use of the 'trace' command so
most people can't imagine using it. I've used it several times in the
past to automagically trigger animations and GUI events using the trace
command. The resulting code is extremely compact and very readable
compared to using other mechanisms like callbacks.

.



Relevant Pages

  • Re: Design question: C command calling back into Tcl
    ... This command produces lots of data. ... The C code puts the data into a C variable which is linked to a Tcl variable and then calls Tcl_UpdateLinkedVar. ... The respective Tcl variable has a write trace which, when activated, will get the current data item and store it somewhere else. ... - Tcl interpreter calls C command ...
    (comp.lang.tcl)
  • Re: Tracing a tcl script
    ... > a trace? ... Tcl procedure. ... command is invoked that contains the name of the command and its arguments. ... each bytecode instruction. ...
    (comp.lang.tcl)
  • Design question: C command calling back into Tcl
    ... - This command produces lots of data. ... - The C code puts the data into a C variable which is linked to a Tcl ... - The respective Tcl variable has a write trace which, when activated, ... - Tcl interpreter calls C command ...
    (comp.lang.tcl)
  • ANN: AOLserver 4.5.0 released!
    ... On behalf of the AOLserver Team, I have the honor of announcing the ... AOLserver 4.5.0 is a major upgrade including several new Tcl commands, ... AOLserver is America Online's Open-Source web server. ... the "ns_zlib" command for compressing and uncompressing ...
    (comp.lang.tcl)
  • Tcl-URL! - weekly Tcl news and links (Mar 5)
    ... GRIDPLUS2 is a Tile based version of GRIDPLUS. ... *) New "gpselect" command to select a tablelist row or tree node. ... Some people take their license issues very personal indeed;-) (and ... Word documents via Tcl and tcom - ...
    (comp.lang.tcl)