Tcl Source Code

View Ticket
Login
Ticket UUID: 29aa1c7b13a6c04400ba1c113d53201f483095f1
Title: Mixed-in destructors aren't called
Type: Bug Created on: 2018-07-17 19:15:02
Submitter: stu Assigned to: nobody
Subsystem: 10. Objects Severity: Minor
Priority: 5 Medium Last modified: 2018-07-19 09:03:30
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: current
Description:
It's also possible that I don't understand what I'm doing.

oo::class create A {destructor {puts a;catch {next}}}
oo::class create B {destructor {puts b};mixin A}
oo::class create C {destructor {puts c}}
foreach i {a b c} {set $i [[string totitle $i] new]}
oo::objdefine $c mixin -append A
foreach i {a b c} {puts $i:;[set $i] destroy}

In the output I expect to see:
c:
a
c
User Comments:
aspect added on 2018-07-19 09:03:30:
Simpler example:

oo::class create A {destructor {puts a;next}}
oo::class create C {destructor {puts c}}

C create c
oo::objdefine c mixin -append A
c destroy

# output: c

The destructor defined in A is never called.  This seems suspicious .. though
note a constructor defined in A will never be called, so maybe it's correct by
symmetry.  Should be documented and covered with a test either way.

Note that you can achieve the desired effect a different way:

oo::define A method destroy {} {puts aa; next}