Ticket UUID: | 1865198 | |||
Title: | Support class methods | |||
Type: | RFE | Version: | None | |
Submitter: | wiede | Created on: | 2008-01-06 17:27:02 | |
Subsystem: | 35. TclOO Package | Assigned To: | dkf | |
Priority: | 7 High | Severity: | ||
Status: | Open | Last Modified: | 2009-08-02 22:22:13 | |
Resolution: | None | Closed By: | ||
Closed on: | ||||
Description: |
There is one function, which is needed in itcl-ng but I think it should be in the TclOO Source code: calling a class method without an object context. This is mostly used for the equivalent of the C++ static class method invocation, which in itcl is called a "class proc". As it mostly does the same as TclOO's InvokeProcedure method and it uses TclOO internal stuff, I think it should be added to TclOO source code. A prototype implementation, which is used at the moment in itcl-ng is in the attachment. | |||
User Comments: |
dkf added on 2009-08-02 22:22:13:
I've attached a Tcl script that allows the declaration of class methods, and which also supports class variables. dkf added on 2009-08-02 22:20:42: File Added - 337678: class.tcl dkf added on 2009-07-12 22:12:19: 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.) dkf added on 2008-05-08 22:22:25: Logged In: YES user_id=79902 Originator: NO Reducing priority; this can be addressed after the TIP#257 vote. wiede added on 2008-01-07 01:29:54: File Added - 261069: classmethodinvoke2.c Logged In: YES user_id=558925 Originator: YES I have added a slightly modified version of the function, which allows me to use it on a second place for itcl ensembles (which are nevertheless mostly running as namespace ensembles already). File Added: classmethodinvoke2.c wiede added on 2008-01-07 00:27:02: File Added - 261064: classmethodinvoke.c |