Skip to content
Tcl Source Code Artifact [4d9f7346cd]
Login

Artifact [4d9f7346cd]

Artifact 4d9f7346cd669d6eb30e7b346bb9d10cbab9bb0de8ca21e3a6ee3a149c8ae24a:

Wiki page [branch/compile-uplevel] by dkf on 2025-06-26 14:43:30.
D 2025-06-26T14:43:30.536
L branch/compile-uplevel
N text/x-markdown
U dkf
W 770
Adds compilation for the `uplevel` command. This requires one new opcodes, `INST_UPLEVEL`, that takes two values on the stack (`level`, `script`) and produces one (`result`). Concatenation of arguments, if required, is handled by the compiled instruction sequence.

Note that the compiler requires the first argument to be known at compile time (so it can be definitely parsed to see if it is a level), and _cannot_ handle a call with a single argument. This is caused by a flaw in the semantics of, say, `uplevel 1` which currently parses as an error in all cases. The correct fix, similar to how `switch` was also fixed, is to say that when a single argument is present, it is _always_ a script and never interpreted as anything else. This will require a TIP to fix.
Z 978f49318d1c21b59d8dbf02f2f6797c