Control table: Difference between revisions

Content deleted Content added
Examples: Remove assembly example; _way_ too complicated
It's 2-dimensional; not multi (in general)
Line 146:
|}
 
MultiA two-dimensional control tablestable cancould be constructedused thatto cansupport be more complex than the above examples that might test fortesting multiple conditions on multiple inputs or performperforming more than one 'action', based on some matching criteria. An 'action' can include a pointer to another subordinate control table. The simple example below has had an ''implicit'' 'OR' condition incorporated as an extra column (to handle lower case input, however in this instance, this could equally have been handled simply by having an extra entry for each of the lower case characters specifying the same subroutine identifier as the upper case characters). An extra column to count the actual run-time events for each input as they occur is also included.
 
:{| class="wikitable"
Line 261:
If the control tables technique could be said to belong to any particular [[programming paradigm]], the closest analogy might be automata-based programming or [[reflection (computer science)|"reflective"]] (a form of [[metaprogramming]] – since the table entries could be said to 'modify' the behaviour of the interpreter). The interpreter itself however, and the subroutines, can be programmed using any one of the available paradigms or even a mixture. The table itself can be essentially a collection of "[[raw data]]" values that do not even need to be compiled and could be read in from an external source (except in specific, platform dependent, implementations using memory pointers directly for greater efficiency).
 
==Analogy to bytecode / virtualVirtual machine instruction set==
A multitwo-dimensional control table hasis somesimilar conceptualto similaritiesintermediate to[[executable code]] (i.e. [[bytecode]]) operatingrunning on a [[virtual machine]], in that a [[platform dependent |platform-dependent]] [[Interpreter (computing)|"interpreter"]] program is usually required to perform the actual execution (that is largely conditionally determined by the tablestable content). There are also some conceptual similarities to the recent [[Common Intermediate Language]] (CIL) in the aim of creating a common intermediate 'instruction set' that is independent of platform (but unlike CIL, no pretensions to be used as a common resource for other languages). [[p-code machine |P-code]] can also be considered a similar but earlier implementation with origins as far back as 1966.
 
==Instruction fetch==
When a multitwo-dimensional control table is used to determine program flow, the normal "hardware" [[program counter]] function is effectively simulated with either a [[Pointer (computer programming)|pointer]] to the first (or next) table entry or else an [[array index |index]] to it. "Fetching" the instruction involves decoding the ''data'' in that table entry – without necessarily copying all or some of the data within the entry first. Programming languages that are able to use [[Pointer (computer programming)|pointer]]s have the dual advantage that less [[Computational overhead|overhead]] is involved, both in accessing the contents and also advancing the counter to point to the next table entry after execution. Calculating the next 'instruction' address (i.e. table entry) can even be performed as an optional additional action of every individual table entry allowing [[Program loops|loops]] and or [[Branch (computer science)|jump]] instructions at any stage.
 
==Monitoring control table execution==
Line 292:
==Disadvantages==
* training requirement – application programmers are not usually trained to produce generic solutions
The following mainly apply to their use in multitwo-dimensional tables, not the one-dimensional tables discussed earlier.
* [[Computational overhead|overhead]] – some increase because of extra level of [[indirection (programming)|indirection]] caused by virtual instructions having to be 'interpreted' (this however can usually be more than offset by a well designed generic interpreter taking full advantage of efficient direct translate, search and conditional testing techniques that may not otherwise have been utilized)
* Complex [[expression (programming)|expression]]s cannot always be used ''directly'' in data table entries for comparison purposes