Tcl_AllowExceptions(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ Tcl_AllowExceptions ✨

okay so bestie, welcome to the Tcl_AllowExceptions(3tcl) page β€” it's a Tcl library procedure and it's literally about letting your script throw whatever completion code it wants instead of Tcl being like "no πŸ’€, that's an error now."


🌸 SYNOPSIS 🌸

#include <tcl.h>

Tcl_AllowExceptions(interp)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tcl_Interp *interp (in) β€” the interpreter where the script is gonna get evaluated, periodt.

πŸ’– DESCRIPTION πŸ’–

So here's the vibe. When a script gets evaluated at top-level β€” meaning like, no other scripts are pending evaluation when you invoke it β€” and that script finishes with a completion code that is not TCL_OK, not TCL_ERROR, and not TCL_RETURN… Tcl's default behaviour is to be a little dramatic and convert that whole thing into a TCL_ERROR return, with an appropriate message attached. Not it. πŸ™ˆ

The specific Tcl script evaluation procedures that do this are:

  • Tcl_EvalObjEx
  • Tcl_EvalObjv
  • Tcl_Eval
  • Tcl_EvalEx
  • Tcl_GlobalEval
  • Tcl_GlobalEvalObj
  • Tcl_VarEval

<bubble>BUT</bubble> β€” and this is the iconic part β€” if you call Tcl_AllowExceptions immediately before calling one of those procedures, then arbitrary completion codes are permitted from the script, and they get returned without modification. No conversion, no meddling, no notes. πŸ’…

This is highkey useful when the caller can actually deal with exceptions like TCL_BREAK or TCL_CONTINUE in a meaningful way β€” like, the caller knows what to do with them, so let them cook. πŸ”₯


πŸ”‘ KEYWORDS πŸ”‘

continue, break, exception, interpreter


okay that's the whole page, slay πŸ’œ β€” this was Tcl 7.4, dated 7.4, filed under Tcl_AllowExceptions(3tcl), and yes the footer says the same thing as the header because that's just how manpages do. no cap. πŸ¦‹

πŸ“¦ where this page comes from