#3817 overeager compilation

obsolete: 8.5b2
open
3
2008-07-29
2007-10-13
No

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

Discussion

  • miguel sofer

    miguel sofer - 2007-10-13

    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

     
  • Donal K. Fellows

    • priority: 9 --> 8
     
  • Donal K. Fellows

    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.

     
  • miguel sofer

    miguel sofer - 2008-07-29
    • priority: 8 --> 3
     
  • miguel sofer

    miguel sofer - 2008-07-29

    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.