Thursday, March 02, 2006

Lecture 3 (3/3/06) : Objects and OOP

Cover object oriented programming in Spiral. I will go over several examples of OOP in code generator implementation.

Spiral Material


Handout: oop.txt
Demo transcript: oop-demo.txt

Object Model

Spiral's object model is based on the following paper:

David Ungar and Randall BB. Smith
Self: The Power Of Simplicity
Proc. OOPSLA '87
[ps.gz] [Self website]

Interesting quote from above:
Elimination of meta­regress. No object in a class­based system can be self­ sufficient; another object (its class) is needed to express its structure and behavior. This leads to a conceptually infinite meta­regress: a point is an instance of class Point, which is an instance of metaclass Point, which is an instance of metameta­ class Point, ad infinitum. On the other hand, in prototype­based systems an object can include its own behavior; no other object is needed to breathe life into it. Proto­types eliminate meta­regress.

Case study

To better explain and motivate OOP style programming we will use Spiral's internal representation of generated code as a running example.

Micro-update

Today I was trying to finish recursive vector code, and of course lots of other things interfered. Several things happened today:
  • Fixed radix expansion of DftCt with left recursion in Maude, will produce a tail-recursive program, which can be converted into a loop. This has nice parallel with what FLAME is doing.
  • I talked to Franz and there are several issues with scalability of Spiral. We need to be able to compose several different codes: real, complex, FMA, fixed-point, vector, SMP, recursive and so forth.
Automatic iterative DFT construction is very nice, and easy to to in Maude. I will do this one day. Franz also showed me how to get a large sample of iterative variants automatically (Pease, Stockham, Korn-Lambiot, etc).

The scond main issue is scalability of Spiral. Here we came up with a list of TODOs:
  1. RulesFor(pattern, ...) (for example [TRC, [DFT, @]])
  2. Composable unparsers
    1. C99Unparser, TRC, TCR, TCC
    2. Composable CodeRuleTree, or at least one should resolve all conflicts within different modes
    3. This is complete when TCR(RDFT(..)) produces assymmetric code (real input, complex output)
  3. SPL/DP options record expansion. Franz also suggested the idea of "worksheet". Worksheet would keep options along with all intermediate results (ie. ruletree, formula, sigma-spl formula, and finally code). This should simplify conflict resolution
  4. Eliminate all global variables (2 and 3 basically do this)
  5. DP should return code + file where it is stored.