Info commands does not show extension added commands? 
Author Message
 Info commands does not show extension added commands?

As far as I can tell it does not.. Is this a feature or a bug?

(my vote: bug)

Dave LeBlanc



Sun, 17 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?

Quote:

> As far as I can tell it does not..

I cannot confirm this. I did


        % package require Trf
        1.2
        % info commands

And got (shortened somewhat for brevity)

        tkCheckRadioInvoke unstack ... oct ...

as result of the last command. 'unstack' and 'oct' are both commands
from the loaded package.

        (tcl/tk 8.0p2, on Linux)

--
Sincerely,

                        <http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------



Wed, 20 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?
Hmmm.....

When I do package requre registry or package require http or package
require opt, I don't see the command or commands in those packages
when I do an info commands.

In fact, I don't see the procs in those packages either... unless I do
a namespace import ::tcl::*!   (Is namespace tcl different from the
global namespace?)

This is on Tcl8.0.3+ - tclsh80.exe

Dave LeBlanc



Quote:


>> As far as I can tell it does not..

>I cannot confirm this. I did


>    % package require Trf
>    1.2
>    % info commands

>And got (shortened somewhat for brevity)

>    tkCheckRadioInvoke unstack ... oct ...

>as result of the last command. 'unstack' and 'oct' are both commands
>from the loaded package.

>    (tcl/tk 8.0p2, on Linux)

>--
>Sincerely,

>                    <http://www.westend.com/~kupries/>
>-------------------------------------------------------------------------------



Thu, 21 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?

Quote:

> When I do package requre registry or package require http or package
> require opt, I don't see the command or commands in those packages
> when I do an info commands.

Those packages use Tcl's default mechanism of package loading, the
so-called lazy-loading scheme.

[info commands] returns a list of the commands currently loaded in
the interpreter.  For a package Foo which uses the lazy-loading
scheme, the command [package require Foo] does not load any of Foo's
commands into the interpreter (so [info commands] won't show them).
Instead, it registers instructions with Tcl's auto-loader which can
be used to load Foo's commands *if* and *when* they are ever evaluated.

If you want to know what commands are auto-loadable in addition
to what commands are already loaded in the interpreter, you should
examine the indices of the global array auto_index in addition to
the return value of [info commands].

Quote:
> ... (Is namespace tcl different from the global namespace?)

Yes.

Quote:


>>        % package require Trf
>>        1.2
>>        % info commands
>>        tkCheckRadioInvoke unstack ... oct ...

Note that the Trf package does not use the lazy-loading scheme.

--
| Don Porter, D.Sc.   Mathematical and Computational Sciences Division |

| http://math.nist.gov/mcsd/Staff/DPorter/                        NIST |
|______________________________________________________________________|



Fri, 22 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?

Quote:

> Hmmm.....
> When I do package requre registry or package require http or package
> require opt, I don't see the command or commands in those packages
> when I do an info commands.
> In fact, I don't see the procs in those packages either... unless I
> do a namespace import ::tcl::*!  (Is namespace tcl different from
> the global namespace?)

Yes.

And the issue you are talking about is a bit clearer now.

Two things to consider:

1) Package index files generated without any special options to
   'pkg_mkindex' initialize the autoloader array, but nothing
   else. Only the first use of any command/procedure in the extension
   will load the appropriate file and cause them to appear in 'info
   commands' (or 'info procs').

   Use the option -direct to generate index files doing an immediate
   load of the necessary files. This is possible since 8.0.3.

2) 'info commands' implicitly lists only the commands in the current
   *and* in the toplevel namespace (::). The latter is a deviation
   from the description in the manpages.

|     info commands ?pattern?
|             If pattern isn't specified, returns a list of names
|             of  all  the  Tcl commands in the current namespace
|             context, including both the built-in commands writ
|             ten  in  C and the command procedures defined using
|             the proc command.  If pattern  is  specified,  only
|             those  names matching pattern are returned.  Match
|             ing is determined  using  the  same  rules  as  for
|             string match.

   If you want to see the commands available to code in a namespace
   FOO you have to execute:

        namespace inscope FOO info commands

   If you want to know which commands are *defined* in FOO you either
   have to

        set res {}
        foreach c [namespace inscope FOO info commands] {
                if {[string match FOO* [namespace inscope FOO namespace which -command $c]]} {
                        lappend res $c
                }
        }

   or
        filter [namespace inscope FOO info commands] [info commands]

        (under the assumption that 'filter' is a command removing all
        elements from the first list which can be found in the
        second. Set notation: first - last.)

If you are sure that the namespace contains only procedures

         namespace inscope FOO info procs

is sufficient.

--
Sincerely,

                        <http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------



Fri, 22 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?


Quote:
>    If you want to know which commands are *defined* in FOO you either
>    have to

>    set res {}
>    foreach c [namespace inscope FOO info commands] {
>            if {[string match FOO* [namespace inscope FOO namespace which -command $c]]} {
>                    lappend res $c
>            }
>    }

>    or
>    filter [namespace inscope FOO info commands] [info commands]

>    (under the assumption that 'filter' is a command removing all
>         elements from the first list which can be found in the
>         second. Set notation: first - last.)

Or, if you don't mind the extra stuff on the front of each command,
you can use:
    info commands FOO::*

HTH!

Donal.
--

Department of Computer Science, University of Manchester, U.K. +44-161-275-6137
--



Sun, 24 Jun 2001 03:00:00 GMT  
 Info commands does not show extension added commands?


Quote:


> >    If you want to know which commands are *defined* in FOO you either
> >    have to

[overly complicated stuff elided]

Quote:
> Or, if you don't mind the extra stuff on the front of each command,
> you can use:
>     info commands FOO::*

Thanks for the nice idea. What was that about perl the language where
everything can be done in different ways ?      :-).

Ok, and people minding the extra stuff can do:

        set nsname FOO
        set res {}

        foreach c [info commands ${nsname}::*] {
                regsub ^${nsname}:: $c {} c
                lappend res $c
        }

        ... work with res ...

--
Sincerely,

                        <http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------



Sun, 24 Jun 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. request: extension that shows how to create an object command

2. ANNOUNCE: Tk extension for adding canvas commands (on items)

3. a small Tk extension -- adding a command to define bitmap

4. info commands return value altered by execution of command inside a namespace

5. Showing an animated label while command is executed

6. namespace import command causes one Tclx command to not be found but no effect on other Tclx commands!

7. Add shell command to print string

8. adding my load module as a tso command

9. Adding commands written in c/c++ as dynamic libraries

10. TIP #214: Add New Object Introspection Command

11. TIP #208: Add a 'chan' Command

12. TIP #206: Add an [ftruncate] Command

 

 
Powered by phpBB® Forum Software