Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f68c3d39492292b6b92274bd9c476e800f37459c
Ticket: 3485060fffffffffffffffffffffffffffffffff
TclOO: variables not copied when mixins are copied
User & Date: basilik99 on 2012-02-06 19:28:27
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Hi,
    
    I use ActiveState Tcl 8.6.0.0.295132 Beta 6. The following code:
    
    package require TclOO
    oo::class create Mix1 \
    {
       variable Mix1_var
       
       constructor {} \
       {
          set Mix1_var 10
          puts "Mix1 constructor: Mix1_var = $Mix1_var."
          next
       }
    }
    
    oo::class create C1 \
    {
       mixin [oo::copy Mix1 Mix1_copy]
       
       variable C1_var
       
       constructor {} \
       {
          set C1_var 40
          my variable Mix1_var  ;# needed otherwise variable not found (normal behavior)
          puts "C1 constructor: C1_var = $C1_var and Mix1_var = $Mix1_var."
       }
    }
    C1 create objc1
    
    
    gives the output:
    
    Mix1 constructor: Mix1_var = 10.
    can't read "Mix1_var": no such variable
    % puts $errorInfo
    can't read "Mix1_var": no such variable
        while executing
    "puts "C1 constructor: C1_var = $C1_var and Mix1_var = $Mix1_var.""
        (class "::C1" constructor line 4)
        invoked from within
    "next"
        (class "::oo::define::Mix1_copy" constructor line 4)
        invoked from within
    "C1 create objc1"
    
    However, if:
    mixin [oo::copy Mix1 Mix1_copy]
    is replaced by:
    mixin Mix1
    
    then it works without an error. So I suspect variables in a mixin not being copied when the mixin class is copied. Please confirm if it is a bug.
    
    Thanks,
    Etienne
    
  4. foundin changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "basilik99"
  10. subsystem changed to: "35. TclOO Package"
  11. title changed to: "TclOO: variables not copied when mixins are copied"
  12. type changed to: "Bug"