Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9ba87fc8cd1619473d91b4ca702453f886cd89ef
Ticket: 47ac84309bab4719c58a693f5d63d837887f3b17
more (compiled) lreplace madness
User & Date: aspect on 2015-06-22 07:41:25
Changes

  1. icomment:
    <p>It looks to me like compiled lreplace as currently implemented <i>cannot</i> correctly deal with indexes of differing sign (ie, one is an end-based index).
    
    <p><a href="http://core.tcl.tk/tcl/artifact/987b59004f8ac6da?ln=1592-1598">here</a> is the code responsible for the "dropRange" case.  It compiles as the equivalent of:
    
    <pre>concat [lrange $l 0 $idx1-1] [lrange $l $idx2+1 end]</pre>
    
    <p>which is fine in ordinary cases, but fails when one of the indices is <tt>end</tt>-based and <tt>$idx2 < $idx1</tt>.
    
    <p>To fix this, compiled <tt>lreplace</tt> needs to be sensitive to the length of the list it is examining.  Simplest is probably to emit bytecode for <tt>end</tt>-based indexes that does the arithmetic to make them positive.
    
    <p>Since that has to be computed on the stack, and <tt>INST_LIST_RANGE_IMM</tt> seems to need its arguments as immediates, I need advice on what bytecode instructions should be used in this case.
    
  2. login: "aspect"
  3. mimetype: "text/html"