Introspection_Spec.txt edit
- Brief
- outline specification for forthcoming Introspection package as posted to comp.lang.tcl (19-Mar-1999)
Introduction
The aim of this package is to extended the basic introspection functionality of the TCL core (8.0 and above) with a view to aid in meta-programming an AI related tasks. This package is still under active development and there is at present some overlap with a meta programming package which is intended for separate release. The package is intended for release as both open source and open specification.At present TK has not been taken into consideration. Features and suggestions are always welcome (send to Email address below).Features
- aims to provide information on 100% of the internal state of the TCL interpreter
- can optionally be 'installed' to override and extend inbuilt commands or be used via direct calls to the introspection namespace
Basic Installation structure
- package is namespaced
- the main namespace is Introspection
- the Meta namespace refers to a less developed meta-programming package
- package has initialize and terminate routines which should be call prior to loaded and unloading the package respectively
i.e. Introspection::Initialize & Introspection::Terminate
- package has install and uninstall routines which cause the overriding of inbuilt commands (primarily info) and reversion to normal state respectively.
Note: These require the less developed meta-programming package to function i.e. Introspection::Install & Introspection::UnInstall
- package is initially being developed as a pure TCL extension. A compiled C extension (providing functionality not possible in TCL alone) is to follow at a later date.
Shared Command API
Where possible / appropriate all commands are to share the same API with the following basic features- selection of a specific interpreter
- selection of a set of patterns to filter in
- selection of a set of patterns to filter out (antipatterns)
Commands provided
- info namespaces
- recursively list all namespaces in existence in a given interpreter
- info allVars
- list all variables across all namespaces in existence in a given interpreter
- info allProcs
- list all procedures across all namespaces existing in a given interpreter
- info allCommands
- list all commands (compiled procedures - but see note) across all namespaces existing in a given interpreter
- info channels
- list all open channels across all namespaces existing in a given interpreter
- info interps
- list all subinterpreters (across all namespaces) of a given interpreter
- info inbuilt
- returns a list of all builtin/default commands for an interpreter
- info builtin
- boolean predicate returning true if and only if the given procedure name is a builtin/default command of the given interpreter
- info renames
- returns a list of all command renamings that have been done in the given interpreter
- info original
- returns the original name of a procedure
- info renamed
- returns what name has been given to a procedure given its original name
- info compiled
- boolean predicate returning true if and only if the given procedure name is a compiled procedure (i.e. one for which info body would return an error)
- info packages
- lists the packages loaded by a given interpreter (info loaded only lists compiled extensions)
- info args
- lists the arguments of _both_ compiled and interpreted procedures (not possible via TCL alone)
- info default
- lists the default values for arguments of both compiled and interpreted procedures (not possible via TCL alone)
Aside from a myriad other uses, the following give TCL a saveable runtime state. Additional switches will allow the selection of subsets of the state to import or export
- interp export
- allows properties of a given interpreter to be exported (probably as a TCL source file)
- interp import
- allows properties of a given interpreter to be imported
- interp clear
- allows properties of a given interpreter to be reset
Meta programming commands used by introspection package
- Meta::AddSubCommand
- adds a new subcommand to a command (existing or otherwise) (the original is renamed, commands are called through means of a wrapper containing a switch statement)
- Meta::DeleteSubCommand
- removes a subcommand from a command
Status edit
The TCL version of all the above routines is complete (apart from bugs known & unknown :-) with the following exceptions:interp export interp import interp clear info args (not possible in TCL alone) info default (not possible in TCL alone)
Contacts edit
This package is presently being developed by Bruce S. O. Adams in the United KingdomEmail - Home: brucea @ removethis cybernetics . demon . co . uk Work: mailto:bruadams@tycoint.com (answered more frequently but not site of development)
TV Such a shame Tk doesn´t have introspection of some complete kind or (partial) state-saving with some good options. I recall I did my own routines for that back in the 90s, but later on it got hard to simply get all state elements enumerated which should be made compulsory for people writing list-based programs I´d be inclined to think..