eval



eval

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
SEE ALSO
KEYWORDS

___________________________

NAME

eval − Evaluate a Tcl script

SYNOPSIS

eval arg ?arg ...? ___________________________

DESCRIPTION

Eval takes one or more arguments, which together comprise a Tcl script containing one or more commands. 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). Note that the list command quotes sequences of words in such a way that they are not further expanded by the eval command.

EXAMPLES

Often, it is useful to store a fragment of a script in a variable and execute it later on with extra values appended. This technique is used in a number of places throughout the Tcl core (e.g. in fcopy, lsort and trace command callbacks). This example shows how to do this using core Tcl commands:

set script {
puts "logging now"
lappend $myCurrentLogVar
}
set myCurrentLogVar log1
# Set up a switch of logging variable part way through!
after 20000 set myCurrentLogVar log2

for {set i 0} {$i<10} {incr i} {
# Introduce a random delay
after [expr {int(5000 * rand())}]
update ;# Check for the asynch log switch
eval
$script $i [clock clicks]
}

Note that in the most common case (where the script fragment is actually just a list of words forming a command prefix), it is better to use {*}$script when doing this sort of invocation pattern. It is less general than the eval command, and hence easier to make robust in practice. The following procedure acts in a way that is analogous to the lappend command, except it inserts the argument values at the start of the list in the variable:

proc lprepend {varName args} {
upvar 1 $varName var
# Ensure that the variable exists and contains a list
lappend var
# Now we insert all the arguments in one go
set var [eval [list linsert $var 0] $args]
}

However, the last line would now normally be written without eval, like this:

set var [linsert $var 0 {*}$args]

SEE ALSO

catch(n), concat(n), error(3), errorCode(n), errorInfo(n), interp(n), list(n), namespace.conf(5), subst(n), uplevel(n)

KEYWORDS

concatenate, evaluate, script




More Linux Commands

manpages/wmemcmp.3.html
wmemcmp(3) - compare two arrays of wide-characters (ManPage)
The wmemcmp() function is the wide-character equivalent of the memcmp(3) function. It compares the n wide-characters starting at s1 and the n wide-characters st

manpages/XQueryBestSize.3.html
XQueryBestSize(3) - determine efficient sizes (Man Page)....
The XQueryBestSize function returns the best or closest size to the specified size. For CursorShape, this is the largest size that can be fully displayed on the

manpages/iconv_close.3.html
iconv_close(3) - deallocate descriptor for character set con
The iconv_close() function deallocates a conversion descriptor cd previously allocated using iconv_open(3). RETURN VALUE When successful, the iconv_close() func

manpages/new_menu_sp.3ncurses.html
new_menu_sp(3ncurses) - curses screen-pointer extension.....
This implementation can be configured to provide a set of functions which improve the ability to manage multiple screens. This feature can be added to any of th

manpages/aa-status.8.html
aa-status(8) display various information about the current A
aa-status will report various aspects of the current state of AppArmor confinement. By default, it displays the same information as if the --verbose argument we

manpages/XOpenDisplay.3.html
XOpenDisplay(3) - connect or disconnect to X server.........
The XOpenDisplay function returns a Display structure that serves as the connection to the X server and that contains all the information about that X server. X

manpages/XtQueryGeometry.3.html
XtQueryGeometry(3) - query the preferred geometry of a child
To discover a childs preferred geometry, the childs parent sets any changes that it intends to make to the childs geometry in the corresponding fields of the in

manpages/Tcl_ForgetImport.3.html
Tcl_ForgetImport(3) - manipulate namespaces - Linux man page
Namespaces are hierarchic naming contexts that can contain commands and variables. They also maintain a list of patterns that describes what commands are export

manpages/XSetWMProperties.3.html
XSetWMProperties(3) - set standard window properties........
The XSetWMProperties convenience function provides a single programming interface for setting those essential window properties that are used for communicating

manpages/error.8.html
error(8) - Postfix error/retry mail delivery agent (ManPage)
The Postfix error(8) delivery agent processes delivery requests from the queue manager. Each request specifies a queue file, a sender address, the reason for no

manpages/resolver.3.html
resolver(3) - resolver routines (Library - Linux man page)
These functions make queries to and interpret the responses from Internet domain name servers. The res_init() function reads the configuration files (see resolv

manpages/menu_requestname.3menu.html
menu_requestname(3menu) - handle printable menu request name
The function menu_request_name returns the printable name of a menu request code. The function menu_request_by_name searches in the name-table for a request wit





We can't live, work or learn in freedom unless the software we use is free.