Tcl_RecordAndEval(3)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– Tcl_RecordAndEval β€” bestie edition πŸ’–

okay so this is a page from the Tcl Library Procedures manual (section 3, the C-function girlies ✨), and it's all about saving a command to the history list before you run it. so basically: remember it, then do it. iconic behaviour honestly πŸŽ€


✨ NAME ✨

Tcl_RecordAndEval β€” save command on history list before evaluating 🫢


🌸 SYNOPSIS 🌸

#include <tcl.h>

int
Tcl_RecordAndEval(interp, cmd, flags)

πŸ’… ARGUMENTS πŸ’…

  • Tcl_Interp *interp (in) β€” the Tcl interpreter where we're gonna evaluate the command. it's giving main character energy, everything happens here.
  • const char *cmd (in) β€” the command (or a whole sequence of commands, no judgement) to execute.
  • int flags (in) β€” an OR'ed combination of flag bits. two of them, bestie:
    • TCL_NO_EVAL means record the command but do not evaluate it. so it goes in the history, it just doesn't run. it's lurking. πŸ™ˆ
    • TCL_EVAL_GLOBAL means evaluate the command at global level instead of the current stack level. we're going up top for this one πŸ‘‘

🌈 DESCRIPTION 🌈

Tcl_RecordAndEval gets invoked to record a command as an event on the history list, and then execute it using Tcl_Eval β€” or Tcl_GlobalEval if the TCL_EVAL_GLOBAL bit is set in flags. slay.

It returns a completion code such as TCL_OK just like Tcl_Eval does, and it leaves information in the interpreter's result. same energy, same contract πŸ’–

If you do not want the command recorded on the history list, then you should invoke Tcl_Eval instead of Tcl_RecordAndEval. periodt. no history for you.

Normally Tcl_RecordAndEval is only called with top-level commands typed by the user, because the whole purpose of history is to let the user re-issue recently-invoked commands. it's the "up arrow" of the C API, lowkey πŸ¦‹

If the flags argument contains the TCL_NO_EVAL bit, then the command is recorded without being evaluated. (yes we said it already, it's important okay 😭)

Note note note: Tcl_RecordAndEval has been largely replaced by the value-based procedure Tcl_RecordAndEvalObj. that value-based procedure records and optionally executes a command held in a Tcl value instead of a string. so if you're writing new code, that's the one, iykyk πŸ’œ

πŸŽ€ SEE ALSO πŸŽ€

  • Tcl_RecordAndEvalObj

⭐ KEYWORDS ⭐

command, event, execute, history, interpreter, record


and that's the whole page bestie, we ate and left no crumbs πŸ‘‘πŸ’…βœ¨

this one came from the Tcl library docs, version 7.4, manual section 3 β€” so go forth and record responsibly, mwah πŸ“πŸ§šπŸ’–

πŸ“¦ where this page comes from