Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f4dbf2b1da847af98f7ab19bd84e85df1f793d40
Ticket: 402781ffffffffffffffffffffffffffffffffff
Fix for Bug 121072
User & Date: dgp on 2000-12-14 04:13:38
Changes

  1. icomment:
    Here's a script to illustrate the incompatibility:
    
    # FILE: randtest.tcl
    puts [expr srand([lindex $argv 0])]
    puts [expr rand()]
    puts [expr rand()]
    
    The shell tclsh8.3 is Tcl 8.3.2; the shell tclsh8.4
    is the CVS HEAD revision of Tcl on Dec. 12, 2000, plus
    Patch 102781.
    
    On 32-bit SunOS 5.7:
    $ tclsh8.3 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.3 randtest.tcl 137438953472
    integer value too large to represent
        while executing
    "expr srand([lindex $argv 0])"
        invoked from within
    "puts [expr srand([lindex $argv 0])]"
        (file "randtest.tcl" line 1)
    
    $ tclsh8.4 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.4 randtest.tcl 137438953472
    integer value too large to represent
        while executing
    "expr srand([lindex $argv 0])"
        invoked from within
    "puts [expr srand([lindex $argv 0])]"
        (file "randtest.tcl" line 1)
    
    So that's compatible.  Next, on Alpha w/ Gnu C compiler:
    
    $ tclsh8.3 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.3 randtest.tcl 137438953472
    1.00050088856
    0.418434093901
    0.621816196768
    
    $ tclsh8.4 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.4 randtest.tcl 137438953472
    0.242578298898
    0.0134695745136
    0.383138850044
    
    Incompatible, but it must be incompatible to fix
    the bug.
    
    Finally on Alpha with the Compaq C Compiler:
    $ tclsh8.3 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.3 randtest.tcl 137438953472
    0.000500887632603
    0.418418441163
    0.358740620482
    
    $ tclsh8.4 randtest.tcl 10000
    0.0782636925943
    0.377881431662
    0.0532219503323
    
    $ tclsh8.4 randtest.tcl 137438953472
    0.242578298898
    0.0134695745136
    0.383138850044
    
    Incompatible, even though there was no apparent bug
    in Tcl 8.3.
    
    The incompatibility bites only if someone has a script
    like this one where they input seeds >= 2^31, and
    expect the same seed to generate the same sequence
    in Tcl 8.4 that it did in Tcl 8.3 (maybe they're doing
    a long series of simulations, and in the middle their
    sysadmin upgrades the system's installed Tcl from Tcl
    8.3 to Tcl 8.4).
    
    I think this should be noted in ChangeLog and changes,
    but isn't enough of a problem to prevent this fix going
    into Tcl 8.4, or even Tcl 8.3.3.  I'm willing to
    patch the docs, too, if you think it is important enough.
    
    
    
  2. login: "dgp"
  3. mimetype: "text/plain"
  4. username: "dgp"