Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 406af42c23bb0066fe94ffd84d439a75fbd4115c4d55be4285dd51406fdd8d83
Ticket: 6d4319309e906144741e49f8790647b2dffb452a
Parent-Class destructor not invoked with same class-name in different namespace
User & Date: sebres on 2025-02-13 22:06:57
Changes

  1. icomment:
    It seems to be solely Itcl (v.4) issue (thus the correct place for the ticket would be [itcl/ticket](/../itcl/ticket)).
    
    Below enclosed the PoC for tclOO (basis of Itcl since Itcl4), that works as expected:
    
    <details style="padding-left:10pt"><summary>PoC ...</summary>
    
    ```
    namespace eval ::A {}; namespace eval ::B {}
    oo::class create ::A::testCls {
      superclass oo::class
      destructor { puts "bye from ::A::testCls" }
    }
    
    oo::class create ::C::testOtherCls {
      superclass ::A::testCls
      destructor { puts "bye from ::C::testOtherCls"; next }
    }
    oo::class create ::C::testCls {
      superclass ::A::testCls
      destructor { puts "bye from ::C::testCls"; next }
    }
    
    set o [::C::testOtherCls new]
    $o destroy
    puts =================
    set o [::C::testCls new]
    $o destroy
    
    ## results to:
    
    bye from ::C::testOtherCls
    bye from ::A::testCls
    =================
    bye from ::C::testCls
    bye from ::A::testCls
    
    ```
    </details>
    
    Although in tclOO inherited destructor need to be invoked explicitly (using `next`).
    
    I guess, Itcl stores somewhere (hash table?) the chain of destructors by simple name (instead of its reference or fully-qualified name).
    
  2. login: "sebres"
  3. mimetype: "text/x-markdown"