Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-10-28
05:21 • Closed ticket [1821332fff]: TclOO: self caller plus 3 other changes artifact: bfa0035aae user: dkf
05:20 • Ticket [1821332fff]: 4 changes artifact: c0617dc7e2 user: dkf
2007-10-27
19:25 • New ticket [1821332fff]. artifact: 5f3cf04c5b user: nobody

TclOO: [self caller]

Closed / Invalid1821332fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-10-27 19:25:21
I don't know if I'm right here:
(tcl85b1 on WinXP with TclOO01)

------------
package require TclOO

oo::class create test {
    
    method selfcaller {} {
        puts [self caller]
    }
}

set t [test new]

$t selfcaller
------------

Error:
caller is not an object
    while executing
"self caller"
    (class "::test" method "selfcaller" line 2)
    invoked from within
"$t selfcaller"
    (file "sample1.tcl" line 12)

I was expecting a list like:
"[list [self class] [self object] [self method]]"
e.g.:
{::test ::oo::Obj4 selfcaller}
dkfplain2007-10-28 05:20:59
Logged In: YES 
user_id=79902
Originator: NO

That's because that operation returns information about the *caller* of the method if that's also a method. Thus, If you'd done this:

  oo::class create test {
     method foo {} { my bar }
     method bar {} { puts [self caller]; my destroy }
  }
  [test new] foo

you might have ended up with output like this:

  ::test ::oo::Obj6 foo

Returning the other information would have been redundant. :-)
dkf Closed ticket [1821332fff]. [History diff]2007-10-28 05:21:20
Log in (anonymous is fine) to add a comment.