Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3c55c57831200e1fa03357eb64ac4b9a9bc13708
Ticket: 1865198fffffffffffffffffffffffffffffffff
Support class methods
User & Date: dkf on 2009-07-12 22:12:19
Changes

  1. icomment:
    How does a class method work? Is it just like invoking a method on the class object?
    
    If so, can do it like this:
    oo::class create Foo {
        constructor {} {
            interp alias {} [namespace current]::Foo->my {} [info object namespace Foo]::my
        }
        forward foo Foo->my foo
        self method foo {args} {
            puts "[self], $args"
        }
    }
    
    Arguably there's a need for a neater way to do this so that more of the machinery is hidden, but this will work. (Note that this is a real class method; none of the object-specific state variables or methods are visible at all. The method can be invoked just the same on the class object.)
    
    
  2. login: "dkf"
  3. mimetype: "text/plain"
  4. username: "dkf"