Many programmers are familiar with ActiveTcl 8.4, but 8.5 is the new standard and 8.6 is around the corner. These new releases bring many good and significant enhancements to Tcl when used properly. View slides from resident Tcl expert Jeff Hobbs, Director of Engineering at ActiveState and long-time Tcl community leader and member of the Tcl Core Team, as he reviews Tcl 8.5 and gives a sneak peak into what to expect from Tcl 8.6. From infinite precision math to new data structures and with several new commands, this webinar will cover in depth the major changes in Tcl 8.5 and how to take advantage of them, as well as a glimpse of Tcl 8.6. In addition to major changes in 8.5, he will review best practices and tips to ensure a successful migration.
Topics included:
* Useful Tcl 8.5 features (expand and dict, bignums, namespaces and more)
* Why you should upgrade to Tcl 8.6
* Best Practices for upgrading and data migration: what to watch for, what not to worry about
* Tcl 8.6 highlights
4. ActiveState and Tcl
ActiveState provides the Tcl community with…
Improvements to open source Tcl core
Host of the Tcl Developer Xchange
Enterprise support infrastructure
ActiveTcl Business and Enterprise Editions
Professional services for Tcl
High quality development tools
ActiveTcl: batteries-Included free distribution
Komodo IDE: professional IDE with extensive Tcl support
Tcl Dev Kit: essential tools for Tcl programmers
ActiveTcl Pro Studio: Bundle with Tcl Dev Kit, Komodo IDE,
Safari Online
5. Tcl 8.5
Finished after almost 4 years in development
8.5a1 released March 2004
8.5.0 final December 2007
8.5.8 released November 2009
8.5.9 release ETA September 2010
Change in state of stable and beta
8.4.19 last community-based released in April 2008
8.6a1 development initiated April 2008
6. Tcl 8.5 changes
Over 90 new TIPs included in Tcl 8.5
8.5 is 99.99% backwards compatible with 8.4 at
the Tcl level
Exceptions are in error cases
incr auto-initialize
No more integer overflow
Bytecodes have changed - watch version compatibility
ActiveTcl tbcload can load 8.4 bytecodes in 8.5
7. Tcl 8.5 expand and dict
New {*}$aList expansion operator
Replacement for oft-misused eval
eval exec [auto_execok start] [list $url]
=> exec {*}[auto_execok start] $url
New dict data structure
Order-preserving key/value pairs kept as Tcl_Objs
More efficient and nestable
Close pairing with [array get] and lists
Can replace any use of TclX keyed lists
Numerous subcommands for filtering, updating data
Some operations byte-coded
8.4 emulated version in ActiveTcl
8. Tcl 8.5 expr
New expr operators
** (exponentation), min, max, isqrt, bool, entier
in (in list) expr {“b” in {a b c}} => 1
ni (not in list), replaces use of lsearch != -1
New ::tcl::mathfunc namespace for functions
Define expr functions at the Tcl level
New ::tcl::mathop namespace for operations
Allows importing as commands for prefix math
All functions are byte-compiled
No more integer overflow because of bignums
9. Tcl 8.5 bignums
expr 2 ** 1024
179769313486231590772930519078902473361797697894230657
273430081157732675805500963132708477322407536021120113
879871393357658789768814416622492847430639474124377767
893424865485276302219601246094119453082952085005768838
150682342462881473913110540827237163350510684586298239
947245938479716304835356329624224137216
Every single bit hand-verified by Kevin Kenny
Work continuing on performance of bignums
Bignums available for all expressions, but most
indexing is still limited to 32-bit values (ie: string
index, lindex)
Floating point handling improved to reduce
rounding errors
10. Tcl 8.5 list ops
Added lrepeat, lassign, lreverse
lassign is as taken from TclX
lrepeat number element1 ?element2 element3 ...?
Extended lsort, lsearch
lsearch -index -nocase -subindices
lsort -nocase -indices
List indices now support int[+-]int and end[+-]
int syntax
12. Tcl 8.5 clock
Completely revamped clock command
64-bit, new parser, ensemble-based
No more Y2038 issues, even on 32-bit systems
Full localization support
Several new subcommands
clock add
Simplifies date math operations
clock microseconds|milliseconds
Improved resolution
Clock scan and format updated
User-specifiable scan formats
Full set of Olsen timezone data
13. Tcl 8.5 interp
Resource limiting with interp limit command
Time and command count based
Improved background error handling with interp
bgerror
Enhanced debugging with info frame
Returns current command location and information
Understands origin (source, proc, eval, precompiled)
New chan command to consolidate channel
operations
Subsumes most f* file id manipulation commands
Channel reflection exposed at the Tcl level (chan create)
chan truncate added
14. Tcl 8.5 packaging
Enhanced package versioning
Understand a, b designation in version number (8.5a5)
Allow for bounded version ranges
Control preference for stable or latest version available
Tcl Modules (.tm) package handling
Intended to improve packaging long term
tclsh and source -encoding option
encoding dirs
Tcl level control of where to find encodings
15. Tcl 8.5 extras
Enhanced catch and return
Make pure Tcl control structures more powerful
New apply operator for anonymous procedures
(lambda)
apply {x {expr {$x*$x}}} 5 => 25
Several new binary format codes and improved
unsigned value support
%t (tiny/short), %n (normal/int), %m (wide), %r/R (single
precision real), %q/Q (double precision real), %u (unsigned)
scan and format have %llx modifiers
New tcl_platform(pointerSize) element
16. Tcl 8.5 switch and string
switch -regexp can provide submatch
information
switch -matchvar foo -indexvar bar -regexp -- $string {
{w*(e)w*} {
puts "matched [lindex $foo 0] with 'e' at
[lindex $bar 1 0]"
}
...
switch added a -nocase option
New string is list|wideinteger
classifications
New string reverse subcommand
17. Tcl 8.5 gotchas
global varName(elemName) raises an error now
Also for upvar 0 x(1) y(1)
Was previously an impotent operation that created
inaccessible variables
Don’t rely on integer overflow - shouldn’t happen
list properly quotes the # char
tcl_precision now defaults to 0
Auto-initialize for incr
Previously an undefined var would cause an error
Gains semantic parity with append, lappend
18. Tcl 8.6
Currently in active development
8.6a1 development initiated April 2008
8.6b1 released December 2008
8.6b2 release ETA October 2010
Release schedule marching towards final
8.6.0 targeted for 2011
Over 40 TIPs implemented for 8.6
Community driven input
Tcl‘2010, October 2010 in Chicago
http://www.tcl.tk/community/tcl2010/
19. Tcl 8.6 OO
Core OO! (TIP#257,#320)
% oo::class create example {
Major effort by Donal Fellows variable foo
Foundational OO system constructor {{value 10}} {
set foo 0
inspired by XOTcl and snit my bar $value
}
Provided in core (no package) destructor { }
oo::class, oo::define, oo::copy, method bar {input} {
incr foo $input
oo::object, ... }
Class-based object system with }
=> ::example
dynamic redefinition allowed % example create b 4
=> ::b
Per-object customization with % b bar 3
filters, mixins and more => 7
Has C API to create and
manage classes, instances and
methods
20. Tcl 8.6 highlights
Next version of [incr Tcl] (v4) uses TclOO
New non-recursive bytecode engine
Enables coroutines, aka generators
Tcl level coroutines in development
Proper tailcalls
Less stack hammering
C API to allow user commands to be restartable
Simplified Tcl prefix matching
C API for option parsing taken from Tk as well
Thread extension to be included with core sources
Other extensions being considered
21. Tcl 8.6 features
New binary encode|decode with base64
binary is now a namespace ensemble
Ability to cancel script evaluation via interp
cancel
Find insertion point in sorted list lsearch -bisect
Added tcl_platform(pathSeparator) key
Unicode aware string trim*
Grouped sort with lsort -stride
Allow lset to extend lists
lset myList end+1 foo equivalent to lappend myList foo
22. More 8.6 stuff!
Many commands accept nothing gracefully
(TIP#323)
Base-2 support in format and scan with %b
New file tempfile ?nameVar? ?template?
Creates tempfile and returns a channel set f [open $file a]
New try/finally syntax try {
puts $f "oops ..."
try body ?handler...? ?finally script? # ...
} finally {
try { close $f
set f [open $file] }
} trap {POSIX EISDIR} {} {
puts "failed to open $file: it's a directory"
} trap {POSIX ENOENT} {} {
puts "failed to open $file: it doesn't exist"
}
23. But wait, there’s more!
Zlib compression included with new core zlib
command
Builds on standard zlib sources
Full zip and unzip support for gzip and zlib formats
Supports channel streaming for transforms
Includes adler32 and crc32 checksumming
Includes Tcl_Zlib* C API
Enhanced chan command
close can close only read or write side
Anonymous pipes with chan pipe
Tcl level channel transformations chan push|pop
24. And on the C side of 8.6
Make Tcl_Interp opaque
No more interp->result
Use Tcl_GetStringResult(interp) instead
API for interp->errorLine
Access to startup scripts from C
Tcl_Obj *Tcl_GetStartupScript(const char **encodingNamePtr)
void Tcl_SetStartupScript(Tcl_Obj *pathPtr, const char *encodingName)
Portable Tcl_StatBuf access
Tcl_Get*FromStat
25. Tcl 8.6 TDBC
Standard interface for database connectors
Currently has drivers for sqlite, mysql, odbc and
postgres
Leverages TclOO framework
package require tdbc::sqlite3 db transaction {
tdbc::sqlite3::connection create set firstname "Fred"
db "phonebook.sqlite3" set lastname "Flintstone"
$statement foreach row {
set statement [db prepare {
puts [dict get $row phone_num]
SELECT phone_num FROM directory
}
WHERE first_name = :firstname }
AND last_name = :lastname
}] $statement close
db close
26. In summary ...
8.5 is 99% compatible with 8.4 at Tcl level
Stable and ready for all task loads
8.6 currently in beta
Final release ETA 2011
Lots of new features, with more to come
Further discussion at Tcl‘2010, October 2010 in Chicago
http://www.tcl.tk/community/tcl2010/
Tcl Dev Kit and Komodo support both 8.5 and 8.6
Later 8.6 changes may require further updates
28. Thank You!
Get Tcl Dev Kit 5:
Use code ATBE to get $40 off until Sept.15, 2010
Get ActiveTcl Business Edition:
Use code ATBE to get $200 off until Sept.15, 2010
Speak to a representative about
ActiveTcl Enterprise or OEM: 1-866-510-2914
business-solutions@activestate.com
www.activestate.com