Tcl_ExprLong(3tcl)
π Tcl_ExprLong β evaluate an expression π
okay bestie, welcome to the Tcl_ExprLong page from the Tcl Library Procedures β¨ (it's a <pink>3tcl</pink> manual, iykyk). this is the little family of C functions that takes an expression and hands you back the answer β but in four different flavours π. come sit, we're doing this together.
β¨ SYNOPSIS β¨
#include <tcl.h>
int
Tcl_ExprLong(interp, expr, longPtr)
int
Tcl_ExprDouble(interp, expr, doublePtr)
int
Tcl_ExprBoolean(interp, expr, booleanPtr)
int
Tcl_ExprString(interp, expr)
π ARGUMENTS π
Tcl_Interp *interp(in) β the interpreter whose context we're evaluatingexprin, bestie. she's the one holding the vibe.const char *expr(in) β the expression itself, the thing we're evaluating. main character fr.long *longPtr(out) β a pointer to the spot where the integer value of the expression gets stored π«Άint *doublePtr(out) β a pointer to the spot where the floating-point value of the expression gets stored πΈint *booleanPtr(out) β a pointer to the spot where the0/1boolean value of the expression gets stored β
π DESCRIPTION π
so. these four procedures all evaluate the expression given by the expr argument and return the result in one of four different forms. periodt. the expression can have any of the forms accepted by the expr command β so like, all of them, no cap.
β οΈ okay important heads-up: these procedures have been largely replaced by the value-based proceduresTcl_ExprLongObj,Tcl_ExprDoubleObj,Tcl_ExprBooleanObj, andTcl_ExprObj. those value-based girlies evaluate an expression held in a Tcl value instead of a string. and the value argument can retain an internal representation that is more efficient to execute π
the interp argument refers to an interpreter used to evaluate the expression (e.g. for variables and nested Tcl commands) and to return error information. she does the heavy lifting AND the snitching, iconic.
for all of these procedures the return value is a standard Tcl result:
TCL_OKmeans the expression was successfully evaluated β¨TCL_ERRORmeans that an error occurred while evaluating the expression π
if TCL_ERROR is returned then the interpreter's result will hold a message describing the error. and if an error occurs while executing a Tcl command embedded in the expression, then that error will be returned. like, the inner error bubbles right on up. no filter.
if the expression is successfully evaluated, then its value is returned in one of four forms, depending on which procedure is invoked:
Tcl_ExprLongstores an integer value at*longPtr. if the expression's actual value is a floating-point number, then it is truncated to an integer π (yes, truncated, don't come for me). if the expression's actual value is a non-numeric string then an error is returned.Tcl_ExprDoublestores a floating-point value at*doublePtr. if the expression's actual value is an integer, it is converted to floating-point. if the expression's actual value is a non-numeric string then an error is returned.Tcl_ExprBooleanstores a0/1integer value at*booleanPtr. if the expression's actual value is an integer or floating-point number, then they store0at*booleanPtrif the value was zero and1otherwise. if the expression's actual value is a non-numeric string then it must be one of the values accepted byTcl_GetBooleansuch as "yes" or "no", or else an error occurs πTcl_ExprStringreturns the value of the expression as a string stored in the interpreter's result π
π SEE ALSO π
Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj
π KEYWORDS π
boolean, double, evaluate, expression, integer, value, string
and that's the whole page bestie π¦ this one's from Tcl 7.0, and the manual page is literally called Tcl_ExprLong(3tcl). go evaluate something cute, ily, bye πβ¨
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 1989-1993 The Regents of the University of California
- Copyright (c) 1994-1997 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms