Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7dae16dbfb425df7d3174e2a4433f4dd3094f793
Ticket: 633204ffffffffffffffffffffffffffffffffff
catch { return foo } breaks inside proc
User & Date: msofer on 2002-12-17 02:47:30
Changes

  1. icomment:
    Logged In: YES 
    user_id=148712
    
    When compiling the body of 'a', the compiler encounters a
    bcc'ed command 'catch and proceeds to compile its arguments;
    as they are also bcc'ed ('return'), the whole thing gets
    compiled into the body of 'a'.
    
    When compiling 'b', the compiler encounters a non-bcc'ed
    command 'myreturn', and compiles an invocation for it.
    
    The effect at runtime is: the 'return' of 'a' executes in
    the same TEBC instance as the proc body, there is no
    C-return involved. OTOH, the return of 'b' comes from a
    child instance of TEBC, via a real C-return.
    
    The internal return in the first case cannot be handled in
    the same manner: as it essentially executes in the same
    process, the return value of an inlined 'retun -code $x'
    *has* to be $x for (almost) everything to work as it should
    - the exception being what we're talking about here :(
    
    I imagine things could conceivably be repaired, but at a
    high complexity cost in the compiler: the return-compiler
    could check if it is compiling within a catch-range or not,
    and compile-in the correct return code: TCL_OK if it is not
    caught, TCL_RETURN otherwise. New idea, I'll think about
    that ...
    
    
  2. login: "msofer"
  3. mimetype: "text/plain"
  4. username: "msofer"