- Any operation may take operands (parameters, arguments). Example: function foo($arg1, $arg2, $arg3)
- Any operands may have attributes. Example: f(long int $arg1, fancy blue dishwasher $arg2)
- The reader (compiler or interpreter) takes operation + operands and produces instructions that will have the desired effect. This can be done at runtime or at compile time.
Operations, operands, and attributes might be seen respectively as Verbs, Nouns, and Adjectives.
The question of what instructions are to run depends upon the attributes
of the operands. For the simplest example, the code "2 + x" will produce
different instructions depending upon the attributes of x.
small int x = 42
return 2 + x // add ax, 2
long int x = 42
return 2 + x // add eax, 2
float x = 42.0
return 2 + x // fadd(42.0) ; adds to st0
At some point the system determines "x is an int, use integer add"
or "x is a float, use floating point add". The process of compilation
can be described as the resolution of high-level code to lower-level
implementation. This may involve translation through intermediary
An interpreted high-level language will make these determinations at
run time. A compiler may make the process more efficient by stripping out
all of these determinations at compile time. At the most extreme of efficiency
the reader may determine that the code will always produce the same
result (42+2 = 44) and insert the resulting value rather than the
code to produce it.
Optimization vs. reuse
A downside of such optimizations is that it becomes
impossible to modify the behavior of a program at runtime if the
behavior-determining code is optimized out. Correspondingly, an
advantage to keeping code unoptimized is that the program may be
modified by a wrapper that changes the resolution of a function call.
A system could provide the best of both worlds by using an object format
that stores both the optimized version and a high-level interpretation, and
recompiling on the fly when directed to change part of the program. To allow
the recompilation of one subroutine at a time, instead of rebuilding the
whole program, the metadata may include a catalogue of entry points.