Tcl Library Source Code

View Ticket
Login
Ticket UUID: 3609183
Title: ooutil::singleton not working when it is used as mixin class
Type: Bug Version: None
Submitter: kbokng Created on: 2013-03-27 02:39:41
Subsystem: oo::util Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Open Last Modified: 2013-03-27 23:44:22
Resolution: None Closed By:
    Closed on:
Description:
Example of how to use ooutil::singleton at http://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/modules/ooutil/ooutil.html is not working.
Below is the extract of the example from the mentioned website:

oo::class create example {
   self mixin singleton
   method foo {} {self}
}

puts [[example new] foo]
puts [[example new] foo]


I tried it and the return does not shown as the same object reference.
User Comments: andreas_kupries added on 2013-03-27 23:44:22:
Confirmed. I will talk to the original author (Donal Fellows) about this.
It might be that he simply wrote the example wrong. Especially as the
following code does work, using 'singleton' in place of 'class'. 

ooutil::singleton create example {
    method foo {} {self}
}

puts [[example new] foo]
puts [[example new] foo]

Note: Given that the package is named "oo::util" (with ::) I will rename
   ooutil::singleton
to oo::util::singleton
shortly.