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

about "info boy" problem

5 views
Skip to first unread message
Message has been deleted

lzs

unread,
Nov 26, 2009, 11:03:45 PM11/26/09
to
I have run into a strange problem with the "info body" command.
one proc named "findfile" contained in one file works well in another
file,
but if I run "info body findfile" it tells me "findfile isn't a
procedure".
A process can run but it does not exist.This seems strange .Although I
know that
source file3 can solve it,but this is not what I want.

# for example

# in file1 ($auto_path contains file1's dir)
proc findfile {} {
return Hello
}
puts "I don't what to exec this file"


# in file2 , it works
puts [findfile]
->I don't what to exec this file
-> Hello


# in file3 , it fails

puts [info body findfile]

-> "findfile" isn't a procedure ....

if in file3,add "source file1", it will print "I don't what to exec
this file",this is not what I want.
Can anyone tell me how to solve this problem


Don Porter

unread,
Nov 27, 2009, 12:10:58 AM11/27/09
to
lzs wrote:
> ...if I run "info body findfile" it tells me "findfile isn't a
> procedure".
> A <procedure> can run but it does not exist.This seems strange .

That is the nature of auto-loading.

> Although I know that
> source file3 can solve it,but this is not what I want.

...


> Can anyone tell me how to solve this problem

You already know how to solve it, you've just rejected the
answer.

[source $filename] will evaluate the script in the interp,
creating the procedure, which can then have its body
introspected.

If you expect a Tcl interpreter to just know information
about procedures stored in files that it is not allowed
to open and read, then you need think much more clearly
about how procs are created in interps.

I think your use of autoloading has seriously misled you
about the way the language operates. I think you would be
better off making your [source]s explicit.

DGP

Nick Hounsome

unread,
Nov 27, 2009, 7:48:17 AM11/27/09
to

remove the "I don't what to exec" because that is how procs are loaded
and you just have to live with it - Tcl is a dynamic interpreted
language.

If you want to source file1 without running findfile and without
knowing where in the auto_path it is then add a proc to file1:

proc source_file1 {} {}

and invoke that [source_file1] - The auto loader will load findfile as
a side effect and then you can use info body on it.

0 new messages