Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TIP #257 additional introspection options suggestion

2 views
Skip to first unread message

Arnulf Wiedemann

unread,
Oct 9, 2006, 2:21:47 PM10/9/06
to
Hello,
I would find it very helpful, if the "info class <classname> methods"
command would get 3 additional options:
-protection make every entry returned a list of methodname and protection
i.e: {somemethod1 exported} {somemethod2 unexported} ...
-classonly return exactly the methods of that class
-classnames make every entry returned a list of methodname and classname or
together with option -protection a list of methodname
protection and classname
i.e: {somemethod1 exported class1}
{somemethod2 unexported class2}
{somemethod3 localexported class2}

Maybe the same for the "info object <objectname> methods" command

Additionally for the "info object <objectname> vars" something similar to
the above:
-protection make every entry returned a list of varname and protection
i.e: {somevar1 exported} {somevar2 unexported} ...
-classnames make every entry returned a list of varname and classname or
together with option -protection a list of varname
protection and classname
i.e: {somevar1 exported class1}
{somevar2 unexported class2}
{somevar3 localexported class2}

under the assumption that the class+object instance vars I suggested in my
last posting are being implemented
(for being able to implement different private variables with the same name
for different classes in a class hierarchy for itcl)

Comments are welcome

Arnulf

Donal K. Fellows

unread,
Oct 10, 2006, 7:13:51 AM10/10/06
to
Arnulf Wiedemann wrote:
> I would find it very helpful, if the "info class <classname> methods"
> command would get 3 additional options:
> -protection make every entry returned a list of methodname and protection
> -classonly return exactly the methods of that class
> -classnames make every entry returned a list of methodname and classname or
> together with option -protection a list of methodname
> protection and classname

Right now, the [info class methods] stuff (name might change) is
fairly simple-minded. By default, it only returns public method names;
the non-public ones have to be specifically asked for. The code also
does not do traversal of the class hierarchy, since that would be a
much more expensive operation. The net effect of that is that the two
of the parts you're asking for would be constants. So I leave them out.
:-)

> Maybe the same for the "info object <objectname> methods" command

Any change done would be done symmetrically, of course.

> Additionally for the "info object <objectname> vars" something similar to
> the above:
> -protection make every entry returned a list of varname and protection

> -classnames make every entry returned a list of varname and classname or
> together with option -protection a list of varname
> protection and classname

Variables do not have protection (well, concealment) levels, and there
isn't any notion of them belonging to a particular class. Adding it in
in any deep way (i.e., within namespaces) would require a lot of
effort. You could do something which does 90% (for 10% of the effort)
with variable renaming etc. but making it all nicely introspectable
would be quite a bit trickier. Easier to use access methods and so
leverage that part of the object code; overriding the variable and
varname methods in your class would probably be a good way to do this.
Another point to watch out for is that Tcl basic principles that
everything be introspectable in principle, even if doing so isn't
particularly simple; nothing within an interpreter is *truly* private.

As you can probably tell, I'm not in a hurry to do much about this. ;-)
This is particularly true because I tend to regard all variables as
being part of the implementation, and not the interface. (I do the same
in other languages too, FWIW.)

> Comments are welcome

Thank you very much for your suggestions. I'm sorry to be currently
rejecting them. It's just that they're either dependent on a misreading
of the TIP (which perhaps ought to be clearer here) or are dependent on
taking on an area that I've deliberately left out on the grounds of it
being complicated. The variable stuff is worth a revisit in the future
though; I've no idea how much of the work can be done without "core"
changes.

Donal.

Arnulf Wiedemann

unread,
Oct 10, 2006, 2:57:03 PM10/10/06
to
Donal K. Fellows wrote:

> Arnulf Wiedemann wrote:
>> I would find it very helpful, if the "info class <classname> methods"
>> command would get 3 additional options:
>> -protection make every entry returned a list of methodname and
>> protection
>> -classonly return exactly the methods of that class
>> -classnames make every entry returned a list of methodname and
>> classname or
>> together with option -protection a list of methodname
>> protection and classname
>
> Right now, the [info class methods] stuff (name might change) is
> fairly simple-minded. By default, it only returns public method names;
> the non-public ones have to be specifically asked for. The code also
> does not do traversal of the class hierarchy, since that would be a
> much more expensive operation. The net effect of that is that the two
> of the parts you're asking for would be constants. So I leave them out.
> :-)

Looking at your code for the unknown command implementation you have already
a function for getting all the methods of the superclasses, if I understand
that correctly (TclOOGetSortedMethodList). That is what I meant could also
be used for the info command or am I wrong?

was just a question, I will see what I can do with an own implementation. It
should be possible using the Resolver adding trick, I have asked you in one
of my last postings.

Nebvertheless thanks for your argumentation.
Arnulf

>
> Donal.

Donal K. Fellows

unread,
Oct 10, 2006, 6:20:27 PM10/10/06
to
Arnulf Wiedemann wrote:
> Looking at your code for the unknown command implementation you have already
> a function for getting all the methods of the superclasses, if I understand
> that correctly (TclOOGetSortedMethodList). That is what I meant could also
> be used for the info command or am I wrong?

I suppose so, but it's pretty simple Tcl code anyway.

Donal.

0 new messages