From 96466972c70a61becc8c332d0b991038ab7028f1 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 15 Nov 2010 11:24:31 +1000 Subject: Remove the bio extension and add 'copyto' to aio. The bio extension is a hangover from TinyTcl. Since Jim supports binary strings, there isn't much need for it except for 'bio copy'. So move this to aio as 'copyto' and implement 'file copy' in terms of it. Signed-off-by: Steve Bennett --- Tcl_shipped.html | 828 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 613 insertions(+), 215 deletions(-) (limited to 'Tcl_shipped.html') diff --git a/Tcl_shipped.html b/Tcl_shipped.html index ba1d32c..b0a1f85 100644 --- a/Tcl_shipped.html +++ b/Tcl_shipped.html @@ -2,8 +2,8 @@ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> - - + + Jim Tcl(n) + - + +
+

SYNOPSIS

@@ -446,6 +584,8 @@ Jim Tcl(n) Manual Page
+
+

INTRODUCTION

Jim is a reimplementation of Tcl, combining some features from @@ -560,6 +700,8 @@ The history command is not supported

+
+

CHANGES

Since v0.63:

@@ -579,6 +721,11 @@ Add aio $handle filename Add info channels

+
  • +

    +The bio extension is gone. Now aio supports copyto. +

    +
  • Since v0.62:

      @@ -792,6 +939,8 @@ Add try … finally command
    +
    +

    TCL INTRODUCTION

    Tcl stands for tool command language and is pronounced tickle. @@ -835,6 +984,8 @@ the language syntax and the built-in commands that will be available in any application based on Tcl. The individual library procedures are described in more detail in separate manual pages, one per procedure.

    +
    +

    INTERPRETERS

    The central data structure in Tcl is an interpreter (C type Jim_Interp). @@ -847,6 +998,8 @@ the application. Interpreters are relatively lightweight structures. They can be created and deleted quickly, so application programmers should feel free to use multiple interpreters if that simplifies the application.

    +
    +

    DATA TYPES

    Tcl supports only one type of data: strings. All commands, all arguments @@ -867,6 +1020,8 @@ the interpretation, there are three common forms that strings take: commands, expressions, and lists. The major sections below discuss these three forms in more detail.

    +
    +

    BASIC COMMAND SYNTAX

    The Tcl language has syntactic similarities to both the Unix shells @@ -909,6 +1064,8 @@ other forms that will be re-used over time: changes to the command set may cause abbreviations to become ambiguous, resulting in scripts that no longer work.

    +
    +

    COMMENTS

    If the first non-blank character in a command is #, then everything @@ -919,6 +1076,8 @@ braces (this is necessary because when Tcl parses the top-level command it doesn’t yet know that the nested field will be used as a command so it cannot process the nested comment character as a comment).

    +
    +

    GROUPING ARGUMENTS WITH DOUBLE-QUOTES

    Normally each argument field ends at the next white space, but @@ -938,6 +1097,8 @@ and backslash substitutions still occur, as described below. If the first character of a command field is not a quote, then quotes receive no special interpretation in the parsing of that field.

    +
    +

    GROUPING ARGUMENTS WITH BRACES

    Curly braces may also be used for grouping arguments. They are similar @@ -975,6 +1136,8 @@ brace, then neither left nor right braces in the field will be treated specially (except as part of variable substitution; see below).

    +
    +

    COMMAND SUBSTITUTION WITH BRACKETS

    If an open bracket occurs in a field of a command, then command @@ -1023,6 +1186,8 @@ expr $b+2]x between them are not interpreted specially; they are passed through to the argument verbatim.

    +
    +

    VARIABLE SUBSTITUTION WITH $

    The dollar sign ($) may be used as a special shorthand form for @@ -1093,6 +1258,8 @@ argument verbatim.

    completely equivalent to [set a]; it is provided as a convenience to reduce typing.

    + +

    SEPARATING COMMANDS WITH SEMI-COLONS

    Normally, each command occupies one line (the command is terminated by a @@ -1101,6 +1268,8 @@ separator character; multiple commands may be placed on one line by separating them with a semi-colon. Semi-colons are not treated as command separators if they appear within curly braces or double-quotes.

    +
    +

    BACKSLASH SUBSTITUTION

    Backslashes may be used to insert non-printing characters into command @@ -1296,6 +1465,8 @@ most common cases. To produce particularly complicated arguments it is probably easiest to use the format command along with command substitution.

    +
    +

    STRING AND LIST INDEX SPECIFICATIONS

    Many string and list commands take one or more index parameters which @@ -1342,6 +1513,8 @@ specify a position in the string relative to the start or end of the string/list

    +
    +

    COMMAND SUMMARY

      @@ -1406,6 +1579,8 @@ If the first non-blank character of a command is a #, everything
    +
    +

    EXPRESSIONS

    The second major interpretation applied to strings in Tcl is @@ -1772,6 +1947,8 @@ terminate. Instead, the expression should be placed in braces:

    to be delayed; it will be re-done each time the expression is evaluated, which is the desired result.

    + +

    LISTS

    The third major way that strings are interpreted in Tcl is as lists. @@ -1812,6 +1989,8 @@ you to build lists, extract elements from them, search them, and perform other list-related functions.

    Advanced list commands include lrepeat, lreverse, lmap, lassign, lset.

    +
    +

    LIST EXPANSION

    A new addition to Tcl 8.5 is the ability to expand a list into separate @@ -1834,6 +2013,8 @@ the resulting command.

    Note that the official Tcl syntax is {*}, however {expand} is retained for backward compatibility with experimental versions of this feature.

    +
    +

    REGULAR EXPRESSIONS

    Tcl provides two commands that support string matching using regular @@ -1843,7 +2024,8 @@ expressions, regexp and regsub, as well as switch -regexp< POSIX regular expression support, or using the built-in regular expression engine. The differences between these are described below.

    NOTE Tcl 7.x and 8.x use perl-style Advanced Regular Expressions (ARE).

    -

    POSIX Regular Expressions

    +
    +

    POSIX Regular Expressions

    If the system supports POSIX regular expressions, and UTF-8 support is not enabled, this support will be used by default. The type of regular expressions supported are Extended Regular Expressions (ERE) rather than Basic Regular Expressions (BRE). @@ -1852,7 +2034,9 @@ See REG_EXTENDED in the documentation.

    make for the smallest code size, but some features such as UTF-8 and \w, \d, \s are not supported.

    See regex(3) and regex(7) for full details.

    -

    Jim built-in Regular Expressions

    +
    +
    +

    Jim built-in Regular Expressions

    The Jim built-in regulare expression engine may be selected with ./configure --with-jim-regexp or it will be selected automatically if UTF-8 support is enabled.

    This engine supports UTF-8 as well as some ARE features. The differences with both Tcl 7.x/8.x @@ -1895,6 +2079,9 @@ No support for the ? non-greedy quantifier. e.g. *?

    +
    + +

    COMMAND RESULTS

    Each command produces two results: a code and a string. The @@ -1990,6 +2177,8 @@ aborting command interpretation any further.

    The info returncodes command may be used to programmatically map between return codes and names.

    +
    +

    PROCEDURES

    Tcl allows you to extend the command interface by defining @@ -2128,6 +2317,8 @@ invocations of the procedure.

    See the proc command for information on how to define procedures and what happens when they are invoked.

    +
    +

    VARIABLES - SCALARS AND ARRAYS

    Tcl allows the definition of variables and the use of their values @@ -2198,6 +2389,8 @@ p

    1 2 3
    + +

    ARRAYS AS LISTS IN JIM

    Unlike Tcl, Jim can automatically convert between a list (with an even @@ -2229,6 +2422,8 @@ puts $a

    1 one 2 two
    + +

    DICTIONARY VALUES

    Tcl 8.5 introduced the dict command, and Jim Tcl has added a version @@ -2277,12 +2472,15 @@ jim> dict set a 3 T three

    See the dict command for more details.

    + +

    GARBAGE COLLECTION, REFERENCES, LAMBDA

    Unlike Tcl, Jim has some sophistocated support for functional programming. These are described briefly below.

    More information may be found at http://wiki.tcl.tk/13847

    -

    References

    +
    +

    References

    A reference can be thought of as holding a value with one level of indirection, where the value may be garbage collected when unreferenced. Consider the following example:

    @@ -2307,7 +2505,9 @@ New String

    The operation setref replaces the value stored by the reference. If the old value is no longer accessible by any reference, it will eventually be automatically be garbage collected.

    -

    Garbage Collection

    +
    +
    +

    Garbage Collection

    Normally, all values in Tcl are passed by value. As such values are copied and released automatically as necessary.

    With the introduction of references, it is possible to create values whose lifetime @@ -2338,7 +2538,9 @@ f jim> finalize $r newf newf

    -

    Lambda

    +
    +
    +

    Lambda

    Jim provides a garbage collected lambda function. This is a procedure which is able to create an anonymous procedure. Consider:

    @@ -2360,6 +2562,9 @@ when the garbage collector runs.

    jim> rename $f ""
    + + +

    UTF-8 AND UNICODE

    If Jim is built with UTF-8 support enabled (configure --enable-utf), @@ -2374,14 +2579,17 @@ while string length returns the number of characters.

    and string bytelength returns the same value as string length.

    Note that even if UTF-8 support is not enabled, the \uNNNN syntax is still available to embed UTF-8 sequences.

    -

    String Matching

    +
    +

    String Matching

    Commands such as string match, lsearch -glob, array names and others use string pattern matching rules. These commands support UTF-8. For example:

    string match a\[\ua0-\ubf\]b "a\u00a3b"
    -

    format and scan

    +
    +
    +

    format and scan

    format %c allows a unicode codepoint to be be encoded. For example, the following will return a string with two bytes and one character. The same as \ub5

    @@ -2401,7 +2609,9 @@ return a string with three characters, not three bytes.

    scan \u00b5A %c%c a b

    scan %s will also accept a character class, including unicode ranges.

    -

    String Classes

    + +
    +

    String Classes

    string is has not been extended to classify UTF-8 characters. Therefore, the following will return 0, even though the string may be considered to be alphabetic.

    @@ -2409,7 +2619,9 @@ will return 0, even though the string may be considered to be alphabetic.

    string is alpha \ub5Test

    This does not affect the string classes ascii, control, digit, double, integer or xdigit.

    -

    Case Mapping and Conversion

    + +
    +

    Case Mapping and Conversion

    Jim provides a simplified unicode case mapping. This means that case conversion and comparison will not increase or decrease the number of characters in a string.

    string toupper will convert any lowercase letters to their uppercase equivalent. @@ -2417,7 +2629,9 @@ Any character which is not a letter or has no uppercase equivalent is left uncha Similarly for string tolower.

    Commands which perform case insensitive matches, such as string compare -nocase and lsearch -nocase fold both strings to uppercase before comparison.

    -

    Invalid UTF-8 Sequences

    +
    +
    +

    Invalid UTF-8 Sequences

    Some UTF-8 character sequences are invalid, such as those beginning with 0xff, those which represent character sequences longer than 3 bytes (greater than U+FFFF), and those which end prematurely, such as a lone 0xc2.

    @@ -2427,11 +2641,16 @@ the following returns 2.

    string bytelength \xff\xff
    -

    Regular Expressions

    + +
    +

    Regular Expressions

    If UTF-8 support is enabled, the built-in regular expression engine will be selected which supports UTF-8 strings and patterns.

    See REGULAR EXPRESSIONS

    + + +

    BUILT-IN COMMANDS

    The Tcl library provides the following built-in commands, which will @@ -2447,7 +2666,8 @@ in ?question-marks?.

    Ellipses () indicate that any number of additional arguments or groups of arguments may appear, in the same format as the preceding argument(s).

    -

    Command Index

    +
    +

    Command Index

    - + - @@ -2481,9 +2700,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2491,9 +2710,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2501,9 +2720,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2511,9 +2730,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2521,9 +2740,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2531,9 +2750,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2541,9 +2760,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2551,9 +2770,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2561,9 +2780,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2571,9 +2790,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2581,9 +2800,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2591,9 +2810,9 @@ cellspacing="0" cellpadding="4"> + - @@ -2601,11 +2820,14 @@ cellspacing="0" cellpadding="4"> +

    alias

    append

    array

    bio

    break

    case

    case

    catch

    cd

    clock

    collect

    concat

    continue

    curry

    curry

    dict

    env

    eof

    errorInfo

    eval

    eventloop

    exec

    exec

    exit

    expr

    file

    flush

    for

    foreach

    format

    format

    getref

    gets

    glob

    if

    incr

    info

    join

    join

    kill

    lambda

    lappend

    lindex

    linsert

    list

    llength

    llength

    lmap

    load

    local

    lrepeat

    lreplace

    lreverse

    lsearch

    lsearch

    lset

    lsort

    open

    os.gethostname

    os.getids

    os.uptime

    os.wait

    os.wait

    package

    pid

    posix

    puts

    pwd

    rand

    range

    range

    read

    ref

    regexp

    rename

    return

    scan

    seek

    seek

    set

    setref

    signal

    socket

    source

    split

    stackdump

    stackdump

    stacktrace

    string

    subst

    syslog

    tailcall

    tell

    throw

    throw

    time

    try

    unknown

    update

    uplevel

    upvar

    vwait

    vwait

    while

    -

    alarm

    +
    +
    +

    alarm

    alarm seconds

    Delivers the SIGALRM signal to the process after the given number of seconds. If the platform supports ularm(3) then @@ -2613,7 +2835,9 @@ the argument may be a floating point value. Otherwise it must be an integer.

    Note that unless a signal handler for SIGALRM has been installed (see signal), the process will exit on this signal.

    -

    alias

    +
    +
    +

    alias

    alias name args…

    Creates a single word alias (proc) for one or more words. For example, the following creates an alias for the command info exists.

    @@ -2626,7 +2850,9 @@ if {[e var]} {

    alias returns name, allowing it to be used with 'local.

    See also proc, curry, lambda, local.

    -

    append

    +
    +
    +

    append

    append varName value ?value value …?

    Append all of the value arguments to the current value of variable varName. If varName doesn’t exist, @@ -2636,7 +2862,9 @@ it is given a value equal to the concatenation of all the variables incrementally. For example, append a $b is much more efficient than set a $a$b if $a is long.

    -

    array

    +
    +
    +

    array

    array option arrayName ?arg arg …?

    This command performs one of several operations on the variable given by arrayName.

    @@ -2726,12 +2954,16 @@ command. The legal options (which may be abbreviated) are:

    -

    break

    + +
    +

    break

    break

    This command may be invoked only inside the body of a loop command such as for or foreach or while. It returns a JIM_BREAK code to signal the innermost containing loop command to return immediately.

    -

    case

    +
    +
    +

    case

    case string ?in? patList body ?patList body …?

    case string ?in? {patList body ?patList body …?}

    Note that the switch command should generally be preferred unless compatibility @@ -2787,7 +3019,9 @@ cases.

    }

    will return 2.

    -

    catch

    + +
    +

    catch

    catch ?-?no?code …? ?--? command ?resultVarName? ?optionsVarName?

    The catch command may be used to prevent errors from aborting command interpretation. Catch evalues command, and returns a @@ -2833,13 +3067,17 @@ The set of codes which will be caught may be modified by specifying the one more

    The use of -- is optional. It signifies that no more return code options follow.

    Note that if a signal marked as signal handle is caught with catch -signal, the return value (stored in resultVarName) is name of the signal caught.

    -

    cd

    +
    +
    +

    cd

    cd dirName

    Change the current working directory to dirName.

    Returns an empty string.

    This command can potentially be disruptive to an application, so it may be removed in some applications.

    -

    clock

    +
    +
    +

    clock

    clock seconds @@ -2869,19 +3107,25 @@ be removed in some applications.

    -

    close

    +
    +
    +

    close

    close fileId

    fileId close

    Closes the file given by fileId. fileId must be the return value from a previous invocation of the open command; after this command, it should not be used anymore.

    -

    collect

    +
    +
    +

    collect

    collect

    Normally reference garbage collection is automatically performed periodically. However it may be run immediately with the collect command.

    See GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    concat

    +
    +
    +

    concat

    concat arg ?arg …?

    This command treats each argument as a list and concatenates them into a single list. It permits any number of arguments. For example, @@ -2896,13 +3140,17 @@ the command

    a b c d e f {g h}

    as its result.

    -

    continue

    + +
    +

    continue

    continue

    This command may be invoked only inside the body of a loop command such as for or foreach or while. It returns a JIM_CONTINUE code to signal the innermost containing loop command to skip the remainder of the loop’s body but continue with the next iteration of the loop.

    -

    curry

    +
    +
    +

    curry

    alias args…

    Similar to alias except it creates an anonymous procedure (lambda) instead of a named procedure.

    @@ -2916,7 +3164,9 @@ if {[$e var]} {

    curry returns the name of the procedure.

    See also proc, alias, lambda, local.

    -

    dict

    + +
    +

    dict

    dict option ?arg arg …?

    Performs one of several operations on dictionary values.

    The option argument determines what action is carried out by the @@ -3011,7 +3261,9 @@ command. The legal options are:

    -

    env

    + +
    +

    env

    env ?name? ?default?

    If name is supplied, returns the value of name from the initial environment (see getenv(3)). An error is returned if name does not @@ -3020,7 +3272,9 @@ that value is returned instead.

    If no arguments are supplied, returns a list of all environment variables and their values as {name value …}

    See also the global variable ::env

    -

    eof

    +
    +
    +

    eof

    eof fileId

    fileId eof

    Returns 1 if an end-of-file condition has occurred on fileId, @@ -3028,7 +3282,9 @@ and their values as {name value …}

    fileId must have been the return value from a previous call to open, or it may be stdin, stdout, or stderr to refer to one of the standard I/O channels.

    -

    error

    +
    +
    +

    error

    error message ?stacktrace?

    Returns a JIM_ERR code, which causes command interpretation to be unwound. message is a string that is returned to the application @@ -3046,7 +3302,9 @@ of the error:

    error $errMsg [info stacktrace]

    See also errorInfo, info stacktrace, catch and return

    -

    errorInfo

    + +
    +

    errorInfo

    errorInfo error ?stacktrace?

    Returns a human-readable representation of the given error message and stack trace. Typical usage is:

    @@ -3058,7 +3316,9 @@ Typical usage is:

    }

    See also error.

    -

    eval

    + +
    +

    eval

    eval arg ?arg …?

    eval takes one or more arguments, which together comprise a Tcl command (or collection of Tcl commands separated by newlines in the @@ -3066,7 +3326,9 @@ usual way). eval concatenates all its arguments in the same fashion as the concat command, passes the concatenated string to the Tcl interpreter recursively, and returns the result of that evaluation (or any error generated by it).

    -

    exec

    +
    +
    +

    exec

    exec arg ?arg …?

    This command treats its arguments as the specification of one or more UNIX commands to execute as subprocesses. @@ -3269,18 +3531,24 @@ option in catch) will be set to a list, as follows:

    The environment for the executed command is set from $::env (unless this variable is unset, in which case the original environment is used).

    -

    exit

    + +
    +

    exit

    exit ?returnCode?

    Terminate the process, returning returnCode to the parent as the exit status.

    If returnCode isn’t specified then it defaults to 0.

    Note that exit can be caught with catch.

    -

    expr

    +
    +
    +

    expr

    expr arg

    Calls the expression processor to evaluate arg, and returns the result as a string. See the section EXPRESSIONS above.

    -

    file

    +
    +
    +

    file

    file option name ?arg arg …?

    Operate on a file or a file name. name is the name of a file.

    Option indicates what to do with the file name. Any unique @@ -3553,7 +3821,9 @@ conditional or looping commands, for example:

    if {![file exists foo]} then {error {bad file name}} else {...}
    -

    finalize

    + +
    +

    finalize

    finalize reference ?command?

    If command is omitted, returns the finalizer command for the given reference.

    Otherwise, sets a new finalizer command for the given reference. command may be @@ -3561,7 +3831,9 @@ the empty string to remove the current finalizer.

    The reference must be a valid reference create with the ref command.

    See GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    flush

    +
    +
    +

    flush

    flush fileId

    fileId flush

    Flushes any output that has been buffered for fileId. fileId must @@ -3569,7 +3841,9 @@ have been the return value from a previous call to open, or it may be stdout or stderr to access one of the standard I/O streams; it must refer to a file that was opened for writing. This command returns an empty string.

    -

    for

    +
    +
    +

    for

    for start test next body

    For is a looping command, similar in structure to the C for statement. The start, next, and body arguments must be Tcl command strings, @@ -3588,7 +3862,9 @@ command will return immediately.

    The operation of break and continue are similar to the corresponding statements in C.

    For returns an empty string.

    -

    foreach

    +
    +
    +

    foreach

    foreach varName list body

    foreach varList list ?varList2 list2 …? body

    In this command, varName is the name of a variable, list @@ -3608,7 +3884,9 @@ of the loop are undefined.

    The break and continue statements may be invoked inside body, with the same effect as in the for command.

    foreach returns an empty string.

    -

    format

    +
    +
    +

    format

    format formatString ?arg arg …?

    This command generates a formatted string in the same way as the C sprintf procedure (it uses sprintf in its @@ -3627,12 +3905,16 @@ ASCII character value.

    argument, so backslash sequences in formatString will be handled correctly even if the argument is in braces.

    The return value from format is the formatted string.

    -

    getref

    + +
    +

    getref

    getref reference

    Returns the string associated with reference. The reference must be a valid reference create with the ref command.

    See GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    gets

    +
    +
    +

    gets

    gets fileId ?varName?

    fileId gets ?varName?

    Reads the next line from the file given by fileId and discards @@ -3655,7 +3937,9 @@ at the end of the file.

    fileId must be stdin or the return value from a previous call to open; it must refer to a file that was opened for reading.

    -

    glob

    +
    +
    +

    glob

    glob ?-nocomplain? pattern ?pattern …?

    This command performs filename globbing, using csh rules. The returned value from glob is the list of expanded filenames.

    @@ -3663,7 +3947,9 @@ value from glob is the list of expanded filenames.

    list may be returned; otherwise an error is returned if the expanded list is empty. The -nocomplain argument must be provided exactly: an abbreviation will not be accepted.

    -

    global

    + +
    +

    global

    global varName ?varName …?

    This command is ignored unless a Tcl procedure is being interpreted. If so, then it declares each given varName to be a global variable @@ -3673,7 +3959,9 @@ rather than a local one. For the duration of the current procedure of a local one.

    An alternative to using global is to use the :: prefix to explicitly name a variable in the global scope.

    -

    if

    +
    +
    +

    if

    if expr1 ?then? body1 elseif expr2 ?then? body2 elseif … ?else? ?bodyN?

    The if command evaluates expr1 as an expression (in the same way that expr evaluates its argument). The value of the expression must @@ -3689,7 +3977,9 @@ may also be omitted as long as else is omitted too.

    The return value from the command is the result of the body script that was executed, or an empty string if none of the expressions was non-zero and there was no bodyN.

    -

    incr

    +
    +
    +

    incr

    incr varName ?increment?

    Increment the value stored in the variable whose name is varName. The value of the variable must be integral.

    @@ -3700,7 +3990,9 @@ integer) is added to the value of variable varName; otherwise and also returned as result.

    If the variable does not exist, the variable is implicitly created and set to 0 first.

    -

    info

    + +
    +

    info

    info option ?arg arg …? @@ -3946,13 +4238,17 @@ The legal option's (which may be abbreviated) are:

    -

    join

    +
    +
    +

    join

    join list ?joinString?

    The list argument must be a valid Tcl list. This command returns the string formed by joining all of the elements of list together with joinString separating each adjacent pair of elements.

    The joinString argument defaults to a space character.

    -

    kill

    +
    +
    +

    kill

    kill ?SIG|-0? pid

    Sends the given signal to the process identified by pid.

    The signal may be specified by name or number in one of the following forms:

    @@ -3987,13 +4283,17 @@ string formed by joining all of the elements of list together w

    The special signal name -0 simply checks that a signal could be sent.

    If no signal is specified, SIGTERM is used.

    An error is raised if the signal could not be delivered.

    -

    lambda

    +
    +
    +

    lambda

    lambda args ?statics? body

    The lambda command is identical to proc, except rather than creating a named procedure, it creates an anonymous procedure and returns the name of the procedure.

    See proc and GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    lappend

    +
    +
    +

    lappend

    lappend varName value ?value value …?

    Treat the variable given by varName as a list and append each of the value arguments to that list as a separate element, with spaces @@ -4008,7 +4308,9 @@ For example, lappend a $b is much more efficient than

    set a [concat $a [list $b]]

    when $a is long.

    -

    lassign

    + +
    +

    lassign

    lassign list varName ?varName? …

    This command treats the value list as a list and assigns successive elements from that list to the variables given by the varName arguments in order. If there are more variable names than @@ -4020,7 +4322,9 @@ ments than variables, a list of unassigned elements is returned.

    3 a=1,b=2
    -

    local

    + +
    +

    local

    local args

    Executes it’s arguments as a command (per eval) and considers the return value to be a procedure name, which is marked as having local scope. @@ -4060,7 +4364,9 @@ than waiting until garbage collection.

    ... }
    -

    lindex

    + +
    +

    lindex

    lindex list index

    Treats list as a Tcl list and returns element index from it (0 refers to the first element of the list). @@ -4070,7 +4376,9 @@ braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur.

    If index is negative or greater than or equal to the number of elements in value, then an empty string is returned.

    -

    linsert

    +
    +
    +

    linsert

    linsert list index element ?element element …?

    This command produces a new list from list by inserting all of the element arguments just before the element index @@ -4081,7 +4389,9 @@ beginning of the list. If index is greater than or equal to the number of elements in the list, then the new elements are appended to the list.

    See STRING AND LIST INDEX SPECIFICATIONS for all allowed forms for index.

    -

    list

    +
    +
    +

    list

    list arg ?arg …?

    This command returns a list comprised of all the arguments, arg. Braces and backslashes get added as necessary, so that the index command @@ -4106,11 +4416,15 @@ For example, the command

    a b c d e f {g h}
    -

    llength

    + +
    +

    llength

    llength list

    Treats list as a list and returns a decimal string giving the number of elements in it.

    -

    lset

    +
    +
    +

    lset

    lset varName ?index ..? newValue

    Sets an element in a list.

    The lset command accepts a parameter, varName, which it interprets @@ -4151,7 +4465,9 @@ or equal to zero. The integer appearing in each index argument must be strictly less than the length of the corresponding list. In other words, the lset command cannot change the size of a list. If an index is outside the permitted range, an error is reported.

    -

    lmap

    +
    +
    +

    lmap

    lmap varName list body

    lmap varList list ?varList2 list2 …? body

    lmap is a "collecting foreach" which returns a list of its results.

    @@ -4165,14 +4481,18 @@ jim> lmap a {1 2 3} b {A B C} {list $a $b}

    If the body invokes continue, no value is added for this iteration. If the body invokes break, the loop ends and no more values are added.

    -

    load

    + +
    +

    load

    load filename

    Loads the dynamic extension, filename. Generally the filename should have the extension .so. The initialisation function for the module must be based on the name of the file. For example loading dir/hwaccess.so will invoke the initialisation function, Jim_hwaccessInit. Normally the load command should not be used directly. Instead it is invoked automatically by package require.

    -

    lrange

    +
    +
    +

    lrange

    lrange list first last

    List must be a valid Tcl list. This command will return a new list consisting of elements first through last, inclusive.

    @@ -4185,7 +4505,9 @@ is returned.

    same result as lindex list first (although it often does for simple fields that aren’t enclosed in braces); it does, however, produce exactly the same results as list [lindex list first]

    -

    lreplace

    + +
    +

    lreplace

    lreplace list first last ?element element …?

    Returns a new list formed by replacing one or more elements of list with the element arguments.

    @@ -4203,7 +4525,9 @@ be added to the list in place of those that were deleted.

    the list.

    If no element arguments are specified, then the elements between first and last are simply deleted.

    -

    lrepeat

    + +
    +

    lrepeat

    lrepeat number element1 ?element2 …?

    Build a list by repeating elements number times (which must be a positive integer).

    @@ -4212,7 +4536,9 @@ a positive integer).

    jim> lrepeat 3 a b
     a b a b a b
    -

    lreverse

    + +
    +

    lreverse

    lreverse list

    Returns the list in reverse order.

    @@ -4220,7 +4546,9 @@ a b a b a b
    jim> lreverse {1 2 3}
     3 2 1
    -

    lsearch

    + +
    +

    lsearch

    lsearch ?options? list pattern

    This command searches the elements list to see if one of them matches pattern. If so, the command returns the index of the first matching element (unless the options -all, -inline or -bool are @@ -4307,7 +4635,9 @@ the list are to be matched against pattern and must have one of the values below

    -

    lsort

    +
    +
    +

    lsort

    lsort ?-index listindex? ?-integer|-command cmdname? ?-decreasing|-increasing? list

    Sort the elements of list, returning a new list in sorted order. By default, ASCII sorting is used, with the result in increasing order.

    @@ -4324,7 +4654,9 @@ be any valid list index, such as 1, end or end-2.

    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.

    -

    open

    +
    +
    +

    open

    open fileName ?access?

    open |command-pipeline ?access?

    Opens a file and returns an identifier @@ -4406,7 +4738,9 @@ input unless overridden by the command.

    The pid command may be used to return the process ids of the commands forming the command pipeline.

    See also socket, pid, exec

    -

    package

    +
    +
    +

    package

    package provide name ?version?

    Indicates that the current script provides the package named name. If no version is specified, 1.0 is used.

    @@ -4422,7 +4756,9 @@ or $path/$name.tcl as a script package.

    otherwise if $name.tcl exists it is loaded with the source command.

    If load or source fails, package require will fail immediately. No further attempt will be made to locate the file.

    -

    pid

    + +
    +

    pid

    pid

    pid fileId

    The first form returns the process identifier of the current process.

    @@ -4431,7 +4767,9 @@ of the process ids forming the pipeline in the same form as exec … &am If fileId represents a regular file handle rather than a command pipeline, the empty string is returned instead.

    See also open, exec

    -

    proc

    + +
    +

    proc

    proc name args ?statics? body

    The proc command creates a new Tcl command procedure, name. When the new command is invoked, the contents of body will be executed. @@ -4446,7 +4784,9 @@ execute an explicit return, then its return value is the value of the last command executed in the procedure’s body.

    If an error occurs while executing the procedure body, then the procedure-as-a-whole will return that same error.

    -

    puts

    +
    +
    +

    puts

    puts ?-nonewline? ?fileId? string

    fileId puts ?-nonewline? string

    Writes the characters given by string to the file given @@ -4461,15 +4801,21 @@ but this feature may be suppressed by specifying the -nonewline switch.

    Output to files is buffered internally by Tcl; the flush command may be used to force buffered characters to be output.

    -

    pwd

    +
    +
    +

    pwd

    pwd

    Returns the path name of the current working directory.

    -

    rand

    +
    +
    +

    rand

    rand ?min? ?max?

    Returns a random integer between min (defaults to 0) and max (defaults to the maximum integer).

    If only one argument is given, it is interpreted as max.

    -

    range

    +
    +
    +

    range

    range ?start? end ?step?

    Returns a list of integers starting at start (defaults to 0) and ranging up to but not including end in steps of step defaults to 1).

    @@ -4484,7 +4830,9 @@ jim> range 2 10 4 jim> range 7 4 -2 7 5
    -

    read

    + +
    +

    read

    read ?-nonewline? fileId

    fileId read ?-nonewline?

    read fileId numBytes

    @@ -4499,7 +4847,9 @@ exactly this many bytes will be read and returned, unless there are fewer than bytes are returned.

    fileId must be stdin or the return value from a previous call to open; it must refer to a file that was opened for reading.

    -

    regexp

    + +
    +

    regexp

    regexp ?-nocase? ?-line? ?-indices? ?-start offset? ?-all? ?-inline? ?--? exp string ?matchVar? ?subMatchVar subMatchVar …?

    Determines whether the regular expression exp matches part or all of string and returns 1 if it does, 0 if it doesn’t.

    @@ -4607,7 +4957,9 @@ string otherwise.

    -

    regsub

    + +
    +

    regsub

    regsub ?-nocase? ?-all? ?-line? ?-start offset? ?--? exp string subSpec ?varName?

    This command matches the regular expression exp against string using the rules described in REGULAR EXPRESSIONS @@ -4693,7 +5045,9 @@ backslashes.

    -

    ref

    + +
    +

    ref

    ref string tag ?finalizer?

    Create a new reference containing string of type tag. If finalizer is specified, it is a command which will be invoked @@ -4705,13 +5059,17 @@ no longer accessible.

    +finalizer 'reference string'+

    See GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    rename

    + +
    +

    rename

    rename oldName newName

    Rename the command that used to be called oldName so that it is now called newName. If newName is an empty string (e.g. {}) then oldName is deleted. The rename command returns an empty string as result.

    -

    return

    +
    +
    +

    return

    return ?-code code? ?-errorinfo stacktrace? ?-errorcode errorcode? ?-level n? ?value?

    Return immediately from the current procedure (or top-level command or source command), with value as the return value. If value @@ -4728,7 +5086,9 @@ an example of how this is done.

    If -errorinfo is specified (as returned from info stacktrace) it is used to initialize the stacktrace.

    If -errorcode is specified, it is used to set the global variable $::errorCode.

    -

    scan

    +
    +
    +

    scan

    scan string format varName1 ?varName2 …?

    This command parses fields from an input string in the same fashion as the C sscanf procedure. String gives the input to be parsed @@ -4741,7 +5101,9 @@ only unusual conversion is for %c. For %c conversions a singl character value is converted to a decimal string, which is then assigned to the corresponding varName; no field width may be specified for this conversion.

    -

    seek

    +
    +
    +

    seek

    seek fileId offset ?origin?

    fileId seek offset ?origin?

    Change the current access position for fileId. @@ -4786,7 +5148,9 @@ must be one of the following:

    open, or it may be stdin, stdout, or stderr to refer to one of the standard I/O channels.

    This command returns an empty string.

    -

    set

    + +
    +

    set

    set varName ?value?

    Returns the value of variable varName.

    If value is specified, then set the value of varName to value, @@ -4804,13 +5168,17 @@ or local variable of the procedure, unless the global command has been invoked to declare varName to be global.

    The :: prefix may also be used to explicitly reference a variable in the global scope.

    -

    setref

    +
    +
    +

    setref

    setref reference string

    Store a new string in reference, replacing the existing string. The reference must be a valid reference create with the ref command.

    See GARBAGE COLLECTION, REFERENCES, LAMBDA for more detail.

    -

    signal

    +
    +
    +

    signal

    Command for signal handling.

    See kill for the different forms which may be used to specify signals.

    Commands which return a list of signal names do so using the canonical form: @@ -4907,12 +5275,16 @@ while {1} { # Received SIGHUP, so reconfigure }

    -

    sleep

    + +
    +

    sleep

    sleep seconds

    Pauses for the given number of seconds, which may be a floating point value less than one to sleep for less than a second, or an integer to sleep for one or more seconds.

    -

    source

    +
    +
    +

    source

    source fileName

    Read file fileName and pass the contents to the Tcl interpreter as a sequence of commands to execute in the normal fashion. The return @@ -4922,7 +5294,9 @@ file, then the source command will return that error.

    If a return command is invoked from within the file, the remainder of the file will be skipped and the source command will return normally with the result from the return command.

    -

    split

    +
    +
    +

    split

    split string ?splitChars?

    Returns a list created by splitting string at each character that is in the splitChars argument.

    @@ -4946,16 +5320,22 @@ For example,

    split "Hello world" {}

    returns "H e l l o { } w o r l d".

    -

    stackdump

    + +
    +

    stackdump

    stackdump stacktrace

    Creates a human readable representation of a stack trace.

    -

    stacktrace

    +
    +
    +

    stacktrace

    stacktrace

    Returns a live stack trace as a list of proc file line proc file line …. Iteratively uses info frame to create the stack trace. This stack trace is in the same form as produced by catch and info stacktrace

    See also stackdump.

    -

    string

    +
    +
    +

    string

    string option arg ?arg …?

    Perform one of several string operations, depending on option. The legal options (which may be abbreviated) are:

    @@ -5361,7 +5741,9 @@ Any hexadecimal digit character ([0-9A-Fa-f]).

    -

    subst

    + +
    +

    subst

    subst ?-nobackslashes? ?-nocommands? ?-novariables? string

    This command performs variable substitutions, command substitutions, and backslash substitutions on its string argument and returns the @@ -5382,7 +5764,9 @@ the following script returns xyz {44}, not xyz {$a}.

    set a 44
     subst {xyz {$a}}
    -

    switch

    + +
    +

    switch

    switch ?options? string pattern body ?pattern body …?

    switch ?options? string {pattern body ?pattern body …?}

    The switch command matches its string argument against each of @@ -5489,7 +5873,9 @@ body among several patterns.

    }

    will return 3.

    -

    tailcall

    + +
    +

    tailcall

    tailcall cmd ?arg…?

    The tailcall command provides an optimised way of invoking a command whilst replacing the current call frame. This is similar to exec in Bourne Shell.

    @@ -5511,7 +5897,9 @@ the current call frame. This is similar to exec in Bourne Shell.

    -

    tell

    + +
    +

    tell

    tell fileId

    fileId tell

    Returns a decimal string giving the current access position in @@ -5519,13 +5907,17 @@ proc sub_cmd2 ...

    fileId must have been the return value from a previous call to open, or it may be stdin, stdout, or stderr to refer to one of the standard I/O channels.

    -

    throw

    +
    +
    +

    throw

    throw code ?msg?

    This command throws an exception (return) code along with an optional message. This command is mostly for convenient usage with try.

    The command throw break is equivalent to break. The command throw 20 message can be caught with an on 20 … clause to try.

    -

    time

    +
    +
    +

    time

    time command ?count?

    This command will call the Tcl interpreter count times to execute command (or once if count isn’t @@ -5537,7 +5929,9 @@ specified). It will then return a string of the form

    which indicates the average amount of time required per iteration, in microseconds.

    Time is measured in elapsed time, not CPU time.

    -

    try

    +
    +
    +

    try

    try ?catchopts? tryscript ?on returncodes {?resultvar? ?optsvar?} handlerscript …? ?finally finalscript?

    The try command is provided as a convenience for exception handling.

    This interpeter first evaluates tryscript under the effect of the catch @@ -5575,7 +5969,9 @@ try -signal { handler.

    In any case, the file will be closed via the finally clause.

    See also throw, catch, return, error.

    -

    unknown

    +
    +
    +

    unknown

    unknown cmdName ?arg arg …?

    This command doesn’t actually exist as part of Tcl, but Tcl will invoke it if it does exist.

    @@ -5595,7 +5991,9 @@ or automatically executing unknown commands as UNIX sub-processes.

    change the original command slightly and then (re-)execute it. The result of the unknown command is used as the result for the original non-existent command.

    -

    unset

    + +
    +

    unset

    unset ?-nocomplain? ?--? ?name name …?

    Remove variables. Each name is a variable name, specified in any of the @@ -5608,7 +6006,9 @@ index, then the entire array is deleted.

    An error occurs if any of the variables doesn’t exist, unless -nocomplain is specified. The -- argument may be specified to stop option processing in case the variable name may be -nocomplain.

    -

    uplevel

    +
    +
    +

    uplevel

    uplevel ?level? command ?command …?

    All of the command arguments are concatenated as if they had been passed to concat; the result is then evaluated in the @@ -5649,7 +6049,9 @@ be used to obtain the level of the current procedure.

    Uplevel makes it possible to implement new control constructs as Tcl procedures (for example, uplevel could be used to implement the while construct as a Tcl procedure).

    -

    upvar

    +
    +
    +

    upvar

    upvar ?level? otherVar myVar ?otherVar myVar …?

    This command arranges for one or more local variables in the current procedure to refer to variables in an enclosing procedure call or @@ -5683,7 +6085,9 @@ and it adds two to the value of that variable. Although add2 could have been implemented using uplevel instead of upvar, upvar makes it simpler for add2 to access the variable in the caller’s procedure frame.

    -

    while

    +
    +
    +

    while

    while test body

    The while command evaluates test as an expression (in the same way that expr evaluates its argument). @@ -5698,49 +6102,15 @@ commands may be executed inside body to cause immediate termination of the while command.

    The while command always returns an empty string.

    + + +

    OPTIONAL-EXTENSIONS

    The following extensions may or may not be available depending upon what options were selected when Jim Tcl was built.

    -

    bio

    -

    The bio command provides a way to read and write binary files -from within Tcl. Note that since Jim supports binary strings, the -main use of this command is bio copy to easily copy between file -descriptors.

    -
    -
    -bio read ?-hex? fd var numbytes -
    -
    -

    - Read bytes from a file descriptor. By default the data is not encoded. - Using -hex encodes the data as ascii hex instead. Returns - the number of bytes actually read. -

    -
    -
    -bio write ?-hex? fd buf -
    -
    -

    - Write a string to a file descriptor. If -hex is specified, the - string is expected to be in ascii hexx format. Returns the number - of bytes actually written. -

    -
    -
    -bio copy fromfd tofd ?numbytes? -
    -
    -

    - Copy binary data from the file descriptor fromfd to the - file descriptor tofd. If numbytes is specified, at most that many - bytes will be copied. Otherwise copying continues until the end - of the input file. Returns the number of bytes actually copied. -

    -
    -
    -

    posix: os.fork, os.wait, os.gethostname, os.getids, os.uptime

    +
    +

    posix: os.fork, os.wait, os.gethostname, os.getids, os.uptime

    os.fork @@ -5810,11 +6180,15 @@ uid 1000 euid 1000 gid 100 egid 100
    +
    +
    +

    ANSI I/O (aio) and EVENTLOOP API

    Jim provides an alternative object-based API for I/O.

    See open and socket for commands which return an I/O handle.

    -

    aio

    +
    +

    aio

    $handle read ?-nonewline? ?len? @@ -5841,6 +6215,16 @@ uid 1000 euid 1000 gid 100 egid 100

    +$handle copyto tofd ?size? +
    +
    +

    + Copy bytes to the file descriptor tofd. If size is specified, at most + that many bytes will be copied. Otherwise copying continues until the end + of the input file. Returns the number of bytes actually copied. +

    +
    +
    $handle flush
    @@ -5940,7 +6324,9 @@ uid 1000 euid 1000 gid 100 egid 100

    -

    eventloop: after, vwait, update

    +
    +
    +

    eventloop: after, vwait, update

    The following commands allow a script to be invoked when the given condition occurs. If no script is given, returns the current script. If the given script is the empty, the handler is removed.

    @@ -6066,7 +6452,9 @@ to prevent infinite errors. (A time event handler is always removed after execut

    -

    socket

    +
    +
    +

    socket

    Various socket types may be created.

    @@ -6193,7 +6581,9 @@ $w close
    $r readable ...
    -

    syslog

    +
    +
    +

    syslog

    syslog ?options? ?priority? message

    This command sends message to system syslog facility with given priority. Valid priorities are:

    @@ -6242,6 +6632,9 @@ uucp, local0-local7
    + + +

    BUILT-IN VARIABLES

    The following global variables are created automatically @@ -6359,6 +6752,8 @@ by the Tcl library.

    + +

    LICENCE

    @@ -6406,9 +6801,12 @@ are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the Jim Tcl Project.
    + + +

    -- cgit v1.1