Tcl Source Code

View Ticket
Login
Ticket UUID: 924045
Title: wider use of TclWordKnownAtCompileTime()
Type: RFE Created on: 2004-03-26 17:04:33
Submitter: msofer Assigned to: msofer
Subsystem: 47. Bytecode Compiler Severity:
Priority: 8 Last modified: 2026-11-13 11:18:45
Status: Closed Closed by: serhiy.storchaka
Resolution: Fixed Closed on: 2026-11-13 11:18:43
Version: None
Description:
TclWordKnownAtCompileTime() is currently only used in
compiling [return]; it should be valuable elsewhere in
the compiler, wherever tests like 
   if (tokenPtr->type == TCL_TOKEN_SIMPLE_WORD)
are made. 
It will allow compilation of scripts with a fair amount
of \uHHHH encodings in them, plus backslash-newline in
long literal strings.
User Comments:
msofer added on 2004-03-27 00:06:32:
Logged In: YES 
user_id=148712

oops -this is an RFE, not a patch

andreas_kupries added on 2006-09-30 01:01:27:
Logged In: YES 
user_id=75003

Oh, I have a TclLiteral function in the patch I wrote for
#86/#211. Miguel, I will send you the patch, and maybe I can
use TclWordKnownAtCompileTime as well. Notethat my patch is
against 8.4, not head.

andreas_kupries added on 2006-10-06 01:24:01:
Logged In: YES 
user_id=75003

I have now compared the two functions, i.e. "TclIsLiteral"
and "TclWordKnownAtCompileTime". The general logic used by
both to decide the issue is identical (I am very glad to see
this, as it means that my understanding of the Token types
is likely correct).

What "TclWordKnownAtCompileTime" does beyond "TclIsLiteral"
is to actually assemble the literal value, if requested.

Note: The tclpro checker has commands to decide literal-ness
 and for assembly of the actual literal as well, based on
the  token list structure returned by the commands of the
Tclparser package (exposing the core parser to the script
level). I wonder if something can be done to expose
'TclWordKnownAtCompileTime' as well.

I will remove my TclISLiteral form the patch for 8.5, and
for 8.4 I will rename my function, but keep the reduced API,
i.e. no assembly of a value, only deciding literalness.
However this way the 8.5 function can be seen as 'obvious'
extension of the conditional one going into 8.4 for TIP 211ng

serhiy.storchaka added on 2026-11-13 11:18:45:

TclWordKnownAtCompileTime() is now used throughout the bytecode compiler (tclCompile.c, tclCompCmds*.c, tclCompExpr.c, tclAssembly.c), so words with backslash substitutions are treated as compile-time literals.