| Ticket UUID: | 1283594 | |||
| Title: | $object info self command | |||
| Type: | RFE | Version: | None | |
| Submitter: | coldstore | Created on: | 2005-09-07 05:20:12 | |
| Subsystem: | snit | Assigned To: | duquette | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Open | Last Modified: | 2005-09-09 09:29:14 | |
| Resolution: | Closed By: | |||
| Closed on: | ||||
| Description: |
When an object inherits publically from another, it would sometimes be useful to be able to determine the object name from outside - this suggested instance standard command would enable that, by returning (for any object) its $self value. I don't believe there's any other way to do this introspectively. | |||
| User Comments: |
duquette added on 2005-09-09 09:29:14:
Logged In: YES user_id=372859 OK, I see what you're after. In your example, "x y" can't return the Y object's name; I'm using [namespace ensemble] for the dispatch now, and [namespace ensemble] requires a subcommand. Yes, "info self" would give you what you want; and it would certainly be easy to do. I'll think about it. coldstore added on 2005-09-08 09:35:09: Logged In: YES
user_id=19214
Consider:
package require snit
snit::type Y {
}
snit::type X {
component Y -public y -inherit true
constructor {
install Y using Y %AUTO%
}
}
X x;
# I would like to know what object [x Y m] will be evaluated in.
x Y ;# this could return the Y instance?
x Y self ;# or this?
x Y info self ;# or this?
It came up when I wanted to return a handler object, and
associate some information with the object, and then
retrieve that information on handler completion by using
[upvar self] as an implicit argument.
I couldn't see a way to determine [x Y] easily. I've coded
around it, so it's not a dire need, but it occurred to me as
a possibly useful facility.
Colin.
duquette added on 2005-09-08 07:16:06: Logged In: YES user_id=372859 Hmmm. I'm not sure what you mean by "an object inherits publically from another". Are you referring to the "component" statement's "- inherit" flag? Also, if I implemented an "info self" method, then if set a [$object info self] it should always be the case that "$a eq $object". Unless $object isn't fully qualified--but [namespace which] should help you there. There might, on the other hand, be some point to an "info selfns" method that returns the object's private namespace. If I'm missing the point entirely, please enlighten me! | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki