From Newsgroup: comp.lang.tcl
For those who were interested in TIP 676 (the = command), I am pleased to announce a pure Tcl implementation that achieves most of the same goals, available now for both Tcl 8.6 and 9.x.
Unfortunately TIP 676 was not accepted, but the underlying need it addressed is real. This module, called Colon, is built on Colin Macleod's original pure Tcl prototype parser that underpinned TIP 676, with several enhancements. It is an example of a design-specific "little language" built entirely outside the core, using the existing tcl::unsupported::assemble command for high performance.
Key features:
- Uses : or = as the command name
- Bare variable name expressions only
- Deliberately disallows $var and [command] substitutions -- expressions are always fully known at compile time, which avoids some concerns raised during the TIP 676 discussion
- Multiple statements separated by ' or ; and chained assignment: a = b = 0
- Multi-line expressions with { }
- Array access with comma-separated indices: matrix(i,j)
- Boolean literals true/false
- Native bytecode for lindex, llength, strlen and list, mathfunc for others
Performance:
Used interpretively with caching, the module is approximately 10x slower than braced expr. However, proc= and method= transform expressions at definition time, producing bytecode identical to hand-written set/expr:
proc= box {x y delta tag} {
.canvas addtag $tag {*}[: list(x-delta,x+delta,y-delta,y+delta)]
}
This generates equivalent bytecode of comparable quality:
proc box {x y delta tag} {
.canvas addtag $tag \
[expr {$x-$delta}] [expr {$x+$delta}] \
[expr {$y-$delta}] [expr {$y+$delta}]
}
The module includes a calc= command for toplevel code blocks, and a testbed RSA implementation is included that demonstrates real-world usage. The RSA example is an interactive demonstration of prime generation, key creation, and text encryption and decryption using the RSA algorithm. Thirteen of its procedures were converted to use the : command and proc=, with a round-trip encrypt/decrypt test verifying correct operation. It requires 64-bit Tcl 8.6 or 9.x and can generate keys up to 1024 bits.
An optional C extension (calc.dll / calc.so) provides a small additional performance improvement for interpreted use outside of procs and methods.
The module is pure Tcl, requires no core changes, no TIP, and is completely optional.
Repository and documentation:
https://github.com/rocketship88/colin-parser
Feedback welcome.
Eric
--- Synchronet 3.22a-Linux NewsLink 1.2