Tcl Source Code

View Ticket
Login
Ticket UUID: d06b029d9d0fc9e68288f1a4f5b8635016fdb905
Title: documentation: oo::define instead of oo::objdefine in example for next
Type: Bug Version: 8.6.4
Submitter: peterlewerin Created on: 2015-07-27 14:17:17
Subsystem: 35. TclOO Package Assigned To: dkf
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2015-08-18 12:50:59
Resolution: Fixed Closed By: dkf
    Closed on: 2015-08-18 12:50:59
Description: (text/x-fossil-wiki)
In the documentation for <code>next</code>, in the first example <code>oo::define</code> is called to configure the <code>obj</code> object: this should be <code>oo::objdefine</code>. Similarly in the second example, the <code>demo</code> object is configured using <code>oo::define</code> instead of <code>oo::objdefine</code>.

Corrected code:

<verbatim>
oo::objdefine obj method example args {
    puts "per-object method, args = $args"
    next x {*}$args y
    next
}
</verbatim>

and

<verbatim>
oo::objdefine demo {
    mixin cache
    method compute {a b c} {
        after 3000 ;# Simulate deep thought
        return [expr {$a + $b * $c}]
    }
    method compute2 {a b c} {
        after 3000 ;# Simulate deep thought
        return [expr {$a * $b + $c}]
    }
}
</verbatim>
User Comments: dkf added on 2015-08-18 12:48:12: (text/x-fossil-wiki)
Silly mistake on my part. Might date from when there was no separate oo::objdefine command and oo::define would just magically "do the right thing".