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

namespace import without arguments

13 views
Skip to first unread message

MartinLemburg@UGS

unread,
Nov 24, 2005, 4:36:32 AM11/24/05
to
Hello,

perhabs I overread something inside the man pages, but the command
"namespace import" may be used without arguments, right?

But ... what happens if "namespace import" is used without arguments?
There is no hint in the man pages, and the command itself does not
return an error or something else!

First I thought, it will return all imported commands in the current
namespace, but it didn't!

Could somebody explain?

Best regards,

Martin Lemburg
UGS - Transforming the Process of Innovation

Ronnie Brunner

unread,
Nov 24, 2005, 5:31:01 AM11/24/05
to
MartinLemburg@UGS wrote:
> Hello,
>
> perhabs I overread something inside the man pages, but the command
> "namespace import" may be used without arguments, right?
>
> But ... what happens if "namespace import" is used without arguments?
> There is no hint in the man pages, and the command itself does not
> return an error or something else!
>
> First I thought, it will return all imported commands in the current
> namespace, but it didn't!
>
> Could somebody explain?

It doesn't do anything.

(Internally it just loops over all patterns (= all arguments except
"-force" if given) and imports the procs/commands accordingly. -> If you
don't provide any pattern, it doesn't do anything.)

Ronnie
--
Ronnie Brunner | ronnie....@netcetera.ch
phone +41 (0)44 247 79 79 | fax +41 (0)44 247 70 75
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.ch

MartinLemburg@UGS

unread,
Nov 24, 2005, 5:46:02 AM11/24/05
to
Thanks, Ronnie!

So ... the only way to get all imports is to get the commands inside a
namespace, loop over them and test if the orign is not equal to the
command name?

What's about extending the "namespace import" command to return, if no
pattern is given, all imports inside the current namespace. This would
be similar to "namespace export".

Or would this really break scripts? Because it makes not really sense
to use "namespace import" without arguments, so I expect, that this
wouldn't break existing scripts.

Arjen Markus

unread,
Nov 24, 2005, 6:43:50 AM11/24/05
to
But you can achieve that effect by using namespace import *,
in my opinion, that clearly states what you want: import all
exported procedures.

Regards,

Arjen

Neil Madden

unread,
Nov 24, 2005, 6:53:38 AM11/24/05
to

I think the poster is asking for an introspection capability, so that you can
quickly find out which commands have been imported into a given namespace, e.g.:

namespace eval foo {
namespace import bar::cmda bar::cmdb
}
puts "Commands that have been imported into foo:"
puts [namespace eval foo { namespace import }]
# prints "cmda cmdb"

This seems like quite a sensible suggestion to me, and would be a
straight-forward TIP I think.

Cheers,

-- Neil

Donal K. Fellows

unread,
Nov 24, 2005, 6:58:29 AM11/24/05
to
MartinLemburg@UGS wrote:
> Or would this really break scripts? Because it makes not really sense
> to use "namespace import" without arguments, so I expect, that this
> wouldn't break existing scripts.

It could in theory, but anything that's broken by this deserves it. :-)

Donal.

Ulrich Schöbel

unread,
Nov 24, 2005, 7:20:11 AM11/24/05
to
Hi Martin,

I second this idea.

Please TIP it!

Kind regards

Ulrich

In article <1132829162.4...@z14g2000cwz.googlegroups.com>,

MartinLemburg@UGS

unread,
Nov 24, 2005, 9:37:49 AM11/24/05
to
Ok, I'll try my first tip.

But currently I'm can only work with a computer during my work, so it
needs some time.

And could need some help about finding the right places in the sources
to try a first implementation.

I took a look at the TIP #0-#3 and ... wow ... I think I need really
some time.

Best regards

Donal K. Fellows

unread,
Nov 24, 2005, 10:47:23 AM11/24/05
to
MartinLemburg@UGS wrote:
> Ok, I'll try my first tip.
>
> But currently I'm can only work with a computer during my work, so it
> needs some time.
>
> And could need some help about finding the right places in the sources
> to try a first implementation.
>
> I took a look at the TIP #0-#3 and ... wow ... I think I need really
> some time.

Writing a TIP's easier than it looks because you have me to help. :-)
Basically, write a clear proposal of what you want to do - preferably in
the sort of style you see in many existing TIPs, but you do not need to
worry about the details of how to represent it in the TIP format - and
email it to me. And that's about it[*]. :-)

Once you've allowed a bit of time for feedback on your specific
proposal, write an implementation patch (for this, it should be fairly
easy), post that to the right tracker at SF, and we'll be able to move
forward with getting a vote done and the feature into the core. (The TCT
does not normally vote on TIPs without implementations; we want to make
sure that we don't have accepted features hanging around unimplemented
if at all possible 'cos that sucks.)

Donal.
[* As long as you've remembered to state on the bottom a suitable
copyright clause; have to be somewhat careful on the legal front. ]

0 new messages