Tcl Source Code

View Ticket
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Ticket UUID: 1812624
Title: overeager compilation
Type: Bug Version: obsolete: 8.5b2
Submitter: msofer Created on: 2007-10-13 00:23:11
Subsystem: 47. Bytecode Compiler Assigned To: msofer
Priority: 3 Low Severity:
Status: Open Last Modified: 2008-07-30 06:30:04
Resolution: None Closed By:
    Closed on:
Description:
In 8.4 and 8.5:
 % set x 1; set x [proc set args "return $x"]
 % puts $x

 % set x
 1

What it should be by rule #2 in Tcl.n:
 % set x 1; set x [proc set args "return $x"]
 % puts $x ;# [set] modified before being called
 1
 % set x
 1
User Comments: msofer added on 2008-07-30 06:30:04:
Logged In: YES 
user_id=148712
Originator: YES

Lowering prio: can't be fixed without a change in Tcl.n (or a huge slowdown), we'll live with this one for a while.

dkf added on 2007-10-14 02:14:53:
Logged In: YES 
user_id=79902
Originator: NO

Quite apart from the fact that your example confuses me anyway, it's an example of something that's deeply horrific anyway. And it's impossible to fix without ridiculous contortions; saying that the command to be invoked is looked up before substitution of the arguments is probably sanest. (On the other hand, that gets horrible when commands are autoloaded, as there the substitution order relative to the autoload step is different, with the compiled command being changed as a side-effect. Ugh.)

Since in practice only insane code does this (yes, that makes test suite writers very strange people) I can't see that this is release-critical. It's just one of the Crazy Aunts in Tcl's Attic.

msofer added on 2007-10-13 07:57:32:
Logged In: YES 
user_id=148712
Originator: YES

This is a tough one to fix. One way out is by subtly changing Tcl.n's Rule #2 to ignore the redefinition of a command during the substitution of its arguments, ie
Rule 2': A command is evaluated in three steps. 
 1. the interpreter substitutes the first word, determines the corresponding command
 2. the interpreter substitutes the other words
 3. the command is invoked