New features in Tcl & Tk

After 40 posts with the new and changed features of #Tcl9, we have covered the important and most interesting stuff.

So, let's move on to #Tk9 in the following posts to see what has happened to Tcl's graphical toolkit Tk!

New feature in #Tcl9 – part 40:

TclOO is now even more complete!

- private variables and methods
- class variables and methods
- abstract and singleton classes
- configurable properties
- method -export & method -unexport

This is quite much, and you can read about it e.g. here (not sure this is the complete list though):

πŸ”—https://core.tcl-lang.org/tips/doc/trunk/tip/500.md
πŸ”—https://core.tcl-lang.org/tips/doc/trunk/tip/558.md
πŸ”—https://core.tcl-lang.org/tips/doc/trunk/tip/516.md
πŸ”—https://core.tcl-lang.org/tips/doc/trunk/tip/519.md

Tcl Improvement Proposals: TIP 500: Private Methods and Variables in TclOO

New feature in #Tcl9 – part 39:

When you use numbers, you sometimes also want to check numbers, i.e. of what type they are. These new math functions/commands help:

- new math functions isinf(), isnan(), isnormal(), issubnormal(), isunordered()
- math function int() no longer truncates to word size
- new command [fpclassify] is used to classify a Tcl value into zero/subnormal/normal/infinite/nan

New feature in #Tcl9 – part 38:

Writing numbers

- A number 0NNN (where N is any digit) is no longer automatically octal. For this, there is 0oNNN
- 0dNNN compels decimal interpretation
- you can insert underscores in any number to increase readability: 12_553.67

New feature in #Tcl9 – part 37:

expr – supports comments inside expressions

Now this is really handy! Use this do properly document your overly long expressions easily:

expr {
# compute the sum of everything:
$myNumber + acos(-1) # acos(-1) = PI !
+ 34/double($myNumber) # the 34 is my invention ...
}

Note, that this is not a comment within double quotes or braces ...

New feature in #Tcl9 – part 36:

expr string comparators lt, gt, le, ge

[expr] can now do boolean string comparisons: less than, greater than, less than or equal, and greater than or equal. These compare values using their UNICODE strings unlike with the numeric-preferring < > <= >= comparisons:

% expr {10 > 9}
1
% expr {10 gt 9}
0

New feature in #Tcl9 – part 35:

vwait - controlled by several new options

Which one? Well, all! in Tcl 8.6 vwait did not have any options at all. Now, there are πŸ”Ÿβ—οΈToo many for a short post like this. Have a look yourself:

πŸ”— https://www.tcl-lang.org/man/tcl9.0/TclCmd/vwait.html

New feature in #Tcl9 – part 34:

socket ... -nodelay ... -keepalive ...

Network sockets can now be configured to set or query the TCP keepalive and nodelay options on the socket. Hmm, I have no useful example of this as I haven't actually used `socket` ...

New feature in #Tcl9 – part 33:

regsub -command ... β€” Generate the replacement for a regular expression by calling a command

Sometimes, a simple `regsub` is not good enough. You may need to do more than just substituting matches into placeholders. That is what the new `-command` option is good for. You can provide a command that takes the matches (substrings) and does with them want you want to happen!

New feature in #Tcl9 – part 32:

lsearch ... -stride ... β€” Search a list by groups of items

[lsearch ...] is powerful. For flat lists, the -stride option in Tcl 9 can kind of pretend that your list is "nested". In fact, it groups a number of items and treat them as a unit:

lsearch -stride 3 {a A amen b B bank c C citron} c
6

Here, each three elements "a a amen", "b B bank" and so on are regarded as one group. Together with the `-index` option, you can search in any group element!