#1358 ooutil::singleton not working when it is used as mixin class

open
oo::util (1)
5
2013-03-27
2013-03-27
No

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.

Discussion

  • Andreas Kupries

    Andreas Kupries - 2013-03-27

    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.

     
  • Andreas Kupries

    Andreas Kupries - 2013-03-27
    • labels: 705570 --> oo::util
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks