A Reflexive Language

I was researching the "introspection" feature of Python, and found this interesting article about "Reflexive Languages" (in this specific case, Smalltalk):

"Reflection is the ability of a program to manipulate as data something representing the state of the program during its own execution. There are two aspects of such manipulation : introspection and intercession. Introspection is the ability of a program to observe and therefore reason about its own state. Intercession is the ability of a program to modify its own execution state or alter its own interpretation or meaning. Both aspects require a mechanism for encoding execution state as data; providing such an encoding is called reification"

Even if the precise point at which a language with reflective facilities becomes a reflective language is not well defined (and is an interesting issue that merits examination by the reflective community as a whole), SMALLTALK has one of the most complete sets of reflective facilities of any language in widespread use.

According to the article, "the basic elements of the programming language - classes, methods and generic functions - are made accessible as objects. Because these objects represent fragments of a program, they are given the special name of metaobjects".

Ordinary objects are used to model the real world. Meta-objects describe these ordinary objects. As a consequence, meta-objects mostly describe SMALLTALK entities. We quote non-exhaustively major meta-object classes (classified by subject):

  1. Structure: Behavior, ClassDescription, Class, Metaclass, ClassBuilder
  2. Semantics: Parser, Compiler, Decompiler, ProgamNode, ProgramNodeBuilder, CodeStream
  3. Behavior: CompiledMethod, CompiledBlock, Message, Signal, Exception
  4. Control State: Context, BlockContext, Process, BlockClosure, ProcessorScheduler
  5. Resources: ObjectMemory, MemoryPolicy, WeakArray
  6. Naming: SystemDictionary, NameScope, PoolDictionary
  7. Libraries: MethodDictionary, ClassOrganizer, SystemOrganizer
  8. Environment: Browser, Inspector, Debugger

Complete article:

http://www2.parc.com/csl/groups/sda/projects/reflection96/docs/rivard/rivard.html

-- NelsonFerraz - 27 Aug 2003