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

What is the purpose or benifits of the command "info subcommands"

15 views
Skip to first unread message

CFAN

unread,
May 16, 2007, 8:28:38 AM5/16/07
to
Why Tcl supports so many info commands
for example
info proc ....

So , does this have there real usage or merely grammar sugar.
also I have heard the dynamic language may have its functions ,but why
an how to harness it?

suchenwi

unread,
May 16, 2007, 9:22:40 AM5/16/07
to

Some use [info] much for introspection, some don't. [info procs] can
for instance be helpful if you're debugging a script interactively and
are too lazy to check the sources.
For an introspection example that uses several [info] subcommands to
recreate a proc's definition, in such a form that it can be eval'ed
in, say, another interpreter, see "corp" http://wiki.tcl.tk/15349

A little, but often useful debugging helper is [info level 0] which
returns the call to the current proc.
Or [info script] to make sibling files available for sourcing without
having to give absolute pathnames.
When I'm at some colleague's machine, I often use
[info na] (nameofexecutable) and
[info pa] (patchlevel)
to determine what tclsh is really running.

More on the Wiki, as usual: http://wiki.tcl.tk/1043

Glenn Jackman

unread,
May 16, 2007, 12:09:06 PM5/16/07
to

[info args], [info default] and [info body] are essential for redefining
procs dynamically.


--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry

Darren New

unread,
May 16, 2007, 1:02:16 PM5/16/07
to
Glenn Jackman wrote:
> [info args], [info default] and [info body] are essential for redefining
> procs dynamically.

Or invoking them dynamically, even. See tclhttpd, which takes a web form
as input and matches the fields in the form to the arguments of the
procedure so-invoked. (Very cool idea, I must say.)

--
Darren New / San Diego, CA, USA (PST)
His kernel fu is strong.
He studied at the Shao Linux Temple.

Artur

unread,
May 17, 2007, 3:47:43 AM5/17/07
to

Introspection (or reflection in Java or .NET) are important feature
for handling metadata.
(data about data)
- debugging
- frameworks (persistence)
- serializing
- .NET uses introspection to couple IDE with components or manage
component containers (without painful XML Java descriptor, EJB3.0 is
based now also on reflection)
- introspection allows to use Tcl as one envirorment for runing and
modifing systems
- loose coupling components or modules
- administrate runing systems

XOTclIDE (http://www.xdobry.de) and TclTalk are IDEs, which work only
with help of introspection.
That allows to interactive modifying running system without edit-run-
debug-stop interactions.
They both use "info procs" for it.
Unfortunately introspection in Tcl/Tk is not complete.
So it is impossible to write a GUI-Builder, which relies only on
introspection.
There are no complete introspection API for widgets (only very base
$widget configure)
Many Tcl extensions do not offer introspection at all or does not
allow dynamic modifing data.

Artur

Larry W. Virden

unread,
May 17, 2007, 12:45:25 PM5/17/07
to
On May 17, 3:47 am, Artur <m...@xdobry.de> wrote:

> Unfortunately introspection in Tcl/Tk is not complete.

:


> There are no complete introspection API for widgets (only very base
> $widget configure)

:
Perhaps it would be worthwhile to brainstorm with others on areas
where introspection is needed - and why. It might help motivate
someone to write a TIP (http://tip.tcl.tk/) for filling in the gaps


0 new messages