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?
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
[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
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.
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
> 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