atable
Additional atables to be search when resolving identifier names.
When resolving identifiers without an atable prefix, the system uses a search path. By default at the beginning of a command frame this search path is as follows:
local
scope
parent atable
global
scope is an atable which can be used as a default for new identifiers.
parent atable is relevant only when the current command frame is a function or procedure and is the atable in which the function or procedures resides.
The search_path attribute can be used to add additional atables to this path. There is no need to add an atable which is already one of the above, unless you wish to change the order. For example, defining search_path for the local atable will mean they get searched between local and scope.
Any atables being added to a search path must already exist. By default an atable's search path array is of zero length, i.e. no additions to its search path.
Consider an application containing many methods (functions/procedures). The application will have a controlling atable, here called myapp, and its methods may make many calls to functions and identifiers in another atable called mylib. We want to avoid having to precede all these external calls with ~mylib., so we do the following.
atable myapp # The search path here is local, globalscope = myapp # The search path here is local, myapp, global # and has changed because of the scope assignmentmyapp.search_path = mylib # The search path here is local, myapp, mylib, global # and has changed because search path has been defined for myappprocedure ~myapp.doit { # The search path here will be: local, myapp, mylib, global # formed by local, myapp (the parent atable), # mylib (search_path for myapp), global }
The next (simpler) example just adds an atable to the search path of the current command frame:
# Create the atable atable myapp # Add it to the search path local.search_path = myapp # Define a numeric numeric ~myapp.test_variable = 7 # Display the numeric tell test_variable