command proc|cmd filename line result command arglist
+From a77ef1a6218fad4c928ddbdc03c1aedc41007e70 Mon Sep 17 00:00:00 2001
From: Steve Bennett Jim Tcl v0.80 -
+ Jim Tcl v0.81 -
reference manual for the Jim Tcl scripting language
+TIP 582, comments allowed in expressions
+
+Many commands now accept "safe" integer expressions rather than simple integers:
+
+String and list indexes now accept integer expressions (STRING AND LIST INDEX SPECIFICATIONS)
+
+
+Add the
+Add
+Add support for
+
+Add support for
+
+TIP 526,
- A simple integer, where 0 refers to the first element of the string
+ A simple integer, where
+ Any "safe" expression that evaluates to an integer. A "safe" expression does not perform
+ variable or command subsitution, but is otherwise like a normal expression
+ (see EXPRESSIONS).
+
+ For example
- The sum or difference of the two integers. e.g.
@@ -1779,11 +1855,20 @@ specify a position in the string relative to the start or end of the string/list
- The nth-from-last element of the string or list.
+ The nth-from-last element of the string or list. Again, a "safe" integer expression
+ may be used in place of a simple integer. White space may be used between the operands and operators and
parentheses; it is ignored by the expression processor.
Where possible, operands are interpreted as integer values. Comments are allowed in expressions, beginning with the # character
+and continuing until the end of line or end of expression. Integer values are interpreted as decimal, binary, octal or
hexadecimal if prepended with 0d, 0b, 0o or 0x
respectively. Otherwise they are interpreted as decimal by default.
@@ -2411,6 +2498,11 @@ Support for non-capturing parentheses
+Jim Tcl does not support back references. e.g. NAME
RECENT CHANGES
Changes between 0.80 and 0.81
+
+
loop
, range
, incr
, string
repeat
, lrepeat
, pack
, unpack
, rand
+loop
can now omit the start value
+xtrace
command for execution trace support
+history
keep
+lsearch
-index
and lsearch
-stride
, the latter per TIP 351
+lsort
-index
now supports multiple indices
+lsort
-stride
+open
now supports POSIX-style access arguments
+expr
now only allows a single argument (unless --compat is enabled)
+Changes between 0.79 and 0.80
0
refers to the first element of the string
or list.
integer+integer
or
+integerexpression
+1+2*3
is valid integer expression, but {$x*2-1}
is not.
+ But note that it is possible to use an unbraced expression to allow the Tcl interpreter
+ to expand variables and commands before being parsed as an integer expression.
+integer-integer
+
2+3
refers to the 5th element.
- This is useful when used with (e.g.) $i+1
rather than the more verbose
- [expr {$i+1}]
+ e.g. string repeat a $x*2-1
end
+end
end-integer
+end-integer
+end-integerexpression
+end+integerexpression
end-3
or end-3+2*$n
. Normally it only makes
+ sense to use the end-
form, but if the integer expression is negative, the end
+ form
+ may be used.
(?:…)
Jim Tcl considers that both patterns and strings end at a null character (\x00
)
\1
+
+
-
@@ -4563,7 +4655,7 @@ and there was no bodyN
.
Increment the value stored in the variable whose name is varName
.
The value of the variable must be integral.
If increment
is supplied then its value (which must be an
-integer) is added to the value of variable varName
; otherwise
+integer expression) is added to the value of variable varName
; otherwise
1 is added to varName
.
The new value is stored as a decimal string in variable varName
and also returned as result.
loop var first limit ?incr? body
loop var ?first? limit ?incr? body
Similar to for
except simpler and possibly more efficient.
If incr
is positive, the effect is, equivalent to:
incr
is positive, the effect is, equivalent to: for {set var $first} {$var < $limit} {incr var $incr} $body
While if incr
is negative, the count is downwards.
If incr
is not specified, 1 is used.
+
If first
is not specified, 0 is used.
+If incr
is not specified, 1 is used.
Note that setting the loop variable inside the loop does not
affect the loop count.
first
, limit
and incr
may be any integer expression.
-index indexList
++ This option is designed for use when searching within nested lists. The + indexList gives a path of indices (much as might be used with + the lindex or lset commands) within each element to allow the location + of the term being matched against. +
+-stride strideLength
+
+ If this option is specified, the list is treated as consisting of
+ groups of strideLength elements and the groups are searched by
+ either their first element or, if the -index
option is used,
+ by the element within each group given by the first index passed to
+ -index
(which is then ignored by -index
). The resulting
+ index always points to the first element in a group.
+
+ The list length must be an integer multiple of strideLength, which + in turn must be at least 1. A strideLength of 1 is the default and + indicates no grouping. +
+lsort ?-index listindex? ?-nocase|-integer|-real|-command cmdname? ?-unique? ?-decreasing|-increasing? list
lsort ?options? list
Sort the elements of list
, returning a new list in sorted order.
By default, ASCII (or UTF-8) sorting is used, with the result in increasing order.
If -nocase
is specified, comparisons are case-insensitive.
If -integer
is specified, numeric sorting is used.
If -real
is specified, floating point number sorting is used.
If -command cmdname
is specified, cmdname
is treated as a command
-name. For each comparison, cmdname $value1 $value2
is called which
-should compare the values and return an integer less than, equal
-to, or greater than zero if the $value1
is to be considered less
-than, equal to, or greater than $value2
, respectively.
If -decreasing
is specified, the resulting list is in the opposite
-order to what it would be otherwise. -increasing
is the default.
If -unique
is specified, then only the last set of duplicate elements found in the list will be retained.
-Note that duplicates are determined relative to the comparison used in the sort. Thus if -index 0
is used,
-{1 a}
and {1 b}
would be considered duplicates and only the second element, {1 b}
, would be retained.
If -index listindex
is specified, each element of the list is treated as a list and
-the given index is extracted from the list for comparison. The list index may
-be any valid list index, such as 1
, end
or end-2
.
Note that only one sort type may be selected with -integer
, -real
, -nocase
or -command
+with last option being used.
-integer
++ Sort using numeric (integer) comparison. +
+-real
++ Sort using floating point comparison. +
+-nocase
++ Sort using using string comparison without regard for case. +
+-command cmdname
+
+ cmdname
is treated as a command name. For each comparison,
+ cmdname $value1 $value2
is called which
+ should compare the values and return an integer less than, equal
+ to, or greater than zero if the $value1
is to be considered less
+ than, equal to, or greater than $value2
, respectively.
+
-increasing
++ The resulting list is in ascending order, from smallest/lowest to largest/highest. + This is the default and does not need to be specified. +
+-decreasing
++ The resulting list is in the opposite order to what it would be otherwise. +
+-unique
+
+ Only the last set of duplicate elements found in the list will
+ be retained. Note that duplicates are determined relative to the
+ comparison used in the sort. Thus if -index 0
is used, {1 a}
and
+ {1 b}
would be considered duplicates and only the second element,
+ {1 b}
, would be retained.
+
-index indexList
++ This option is designed for use when sorting nested lists. The + indexList gives a path of indices (much as might be used with + the lindex or lset commands) within each element to specify the + value to be used for comparison. +
+-stride strideLength
+
+ If this option is specified, the list is treated as consisting of
+ groups of strideLength elements and the groups are sorted by
+ either their first element or, if the -index
option is used,
+ by the element within each group given by the first index passed to
+ -index
(which is then ignored by -index
). The resulting list
+ is once again a flat list.
+
+ The list length must be an integer multiple of strideLength, which + in turn must be at least 2. +
+access
defaults to r.
Additionally, if POSIX mode is supported by the underlying system, +then access may insted of consistent of a list of any of the following +flags, all of which have the standard POSIX meanings. In this case, +the first flag must be one of RDONLY, WRONLY or RDWR.
RDONLY
++ Open the file for reading only. +
+WRONLY
++ Open the file for writing only. +
+RDWR
++ Open the file for both reading and writing. +
+APPEND
++ Set the file pointer to the end of the file prior to each write. +
+BINARY
++ Ignored. +
+CREAT
++ Create the file if it does not already exist (without this flag + it is an error for the file not to exist). +
+EXCL
++ If CREAT is also specified, an error is returned if the file + already exists. +
+NOCTTY
++ If the file is a terminal device, this flag prevents the file + from becoming the controlling terminal of the process. +
+TRUNC
++ If the file exists it is truncated to zero length. +
+If a file is opened for both reading and writing, then seek
must be invoked between a read and a write, or vice versa.
If the first character of fileName
is "|" then the remaining
@@ -5486,6 +5781,7 @@ and ranging up to but not including end
in steps of
. range 7 4 -2
7 5
Integer parameters may be any integer expression.
body
to cause immediate
termination of the while
command.The while
command always returns an empty string.
xtrace command
Install an execution trace callback command. This is useful for implementing a debugger +or tracing tool. On each command invocation, the given command is invoked as:
command proc|cmd filename line result command arglist
+proc
or cmd
indicates whether a command or a proc body is being executed.
+filename
and line
indicate the location where the command was invoked.
+result
is the current interpreter result (from the previous command).
+command
and arglist
indicate the command being executed.
While the callback is executing, any further execution traces are temporarily disabled.
+If the callback returns JIM_OK
or JIM_RETURN
, the execution trace is reinstalled. Otherwise
+the execution trace is removed.
If xtrace
is called with an empty argument (""), any existing callback is removed.
history keep ?count?
++ Set or return the maximum history size. Defaults to 100. +
+history save filename