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

Determining name/paths of source-d files at runtime

6 views
Skip to first unread message

Sharad

unread,
Aug 9, 2007, 3:37:12 AM8/9/07
to shara...@gmail.com
Hi

Is there a way in TCL to know (at runtime):
1. Name/Path of all files sourced using source command
2. Name/Path of the file containing a a proc, for e.g., foo, assuming
that the file is sourced in the interpreter and the function
definition is availble.
3. Name/Path of the file containing a a proc, for e.g., foo, assuming
that the file is sourced in the interpreter and the function
definition is availble and the function is invoked. In other words, if
I want to display the path/name of the file and function name upon
invocation.

Any info. will be of great help.

Regard
Sharad

Michael Schlenker

unread,
Aug 9, 2007, 3:54:07 AM8/9/07
to
Sharad schrieb:
Only if you overload the source command with your own version.

info script tells you the info for the running script, and info commands
and friends lets you see what is there so you can note stuff before and
after load.

Michael

Sharad

unread,
Aug 9, 2007, 4:19:01 AM8/9/07
to
Thanks Michael.

I thought of this earlier and just tried it out. This will definitely
work but to me it does not look a very neat approach and is more of a
workaround than a solution. I am trying to evaluate other options, if
there are any, and then implement.

If I do not find anything better, I've no other option than to use
it :-)

Thanks much for the prompt response.

Regards
Sharad

Donal K. Fellows

unread,
Aug 9, 2007, 4:26:28 AM8/9/07
to
Sharad wrote:
> 3. Name/Path of the file containing a a proc, for e.g., foo, assuming
> that the file is sourced in the interpreter and the function
> definition is availble and the function is invoked. In other words, if
> I want to display the path/name of the file and function name upon
> invocation.

In 8.5 you may find that [info frame] is of some interest. Details may
be read at http://www.tcl.tk/man/tcl8.5/TclCmd/info.htm#M12

Donal.

Gerald W. Lester

unread,
Aug 9, 2007, 9:08:50 AM8/9/07
to

How come file is only available for the source type (I'd think it would also
make sense for the precompiled type)?


--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

MartinLemburg@UGS

unread,
Aug 9, 2007, 10:48:47 AM8/9/07
to
> > In 8.5 you may find that [info frame] is of some interest. Details may
> > be read athttp://www.tcl.tk/man/tcl8.5/TclCmd/info.htm#M12

>
> How come file is only available for the source type (I'd think it would also
> make sense for the precompiled type)?

And how comes, that the file is only available while sourcing and not
even afterwards in the scope of a previously source'ed procedure?

Best regards,

Martin

On Aug 9, 3:08 pm, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
> Donal K. Fellows wrote:
> > Sharad wrote:
> >> 3. Name/Path of the file containing a a proc, for e.g., foo, assuming
> >> that the file is sourced in the interpreter and the function
> >> definition is availble and the function is invoked. In other words, if
> >> I want to display the path/name of the file and function name upon
> >> invocation.
>
> > In 8.5 you may find that [info frame] is of some interest. Details may

> > be read athttp://www.tcl.tk/man/tcl8.5/TclCmd/info.htm#M12

Donal K. Fellows

unread,
Aug 9, 2007, 5:17:17 PM8/9/07
to
Gerald W. Lester wrote:
> How come file is only available for the source type (I'd think it would
> also make sense for the precompiled type)?

I suspect it is because if someone is using the precompiled type, they
want to obscure details. Ask the ActiveState-ers if you want a more
definitive answer.

Donal.

Donal K. Fellows

unread,
Aug 9, 2007, 5:23:51 PM8/9/07
to
MartinLemburg@UGS wrote:
> And how comes, that the file is only available while sourcing and not
> even afterwards in the scope of a previously source'ed procedure?

The filename is available for things defined within the context of a
sourced file. But (for reasons that defeat me right now) only when the
frame in question is on the stack. It might be possible in the future to
expose that info in other ways too (e.g. an [info source $proc] or
something like that[*].)

Donal.
[* Not a serious suggestion! Just riffing on the idea. ]

Gerald W. Lester

unread,
Aug 9, 2007, 6:18:11 PM8/9/07
to
Donal K. Fellows wrote:
> MartinLemburg@UGS wrote:
>> And how comes, that the file is only available while sourcing and not
>> even afterwards in the scope of a previously source'ed procedure?
>
> The filename is available for things defined within the context of a
> sourced file. But (for reasons that defeat me right now) only when the
> frame in question is on the stack. It might be possible in the future to
> expose that info in other ways too (e.g. an [info source $proc] or
> something like that[*].)

I like it, I like it!

Sharad

unread,
Aug 10, 2007, 4:45:23 AM8/10/07
to
Even I like it .. something like [info source <proc name>]. But in
case a function is redefined at multiple places/multiples files ..
should it point to one file or all files ...

0 new messages