@TECHREPORT{demf:bryan,
AUTHOR = "Bryan Chadwick and Karl Lieberherr",
TITLE = "{Functional Adaptive Programming with DemeterF}",
YEAR = "2008",
INSTITUTION = "Northeastern University, Boston",
MONTH = "March",
NUMBER = "NU-CCIS-08-March19"
}
Notes by Karl:
The relationships between objects in object-oriented programs are as important as the objects themselves. Unfortunately, most object-oriented programming languages provide little support for such relationships, leaving the task of implementing them entirely to the programmer. Relationships are typically hard-coded into the participating classes, resulting in tangled code that unnecessarily couples these classes together.
In DemeterF we reason in terms of compositions of relations (or paths in class graphs). In the type-unifying case, we rely on the fact that the correct object will appear in a certain position. How it gets there is unknown by the time of the program writing and it is only known when the class graph is given.
T combine(NodeInt o,int i, T l, T r){return fold(l,r);}
means that there must be a T-carrying path to the second
and third argument, but not to the first.
The program should not contain any dead combine methods.
T combine(Object o){return new T(default);}
T combine(NodeInt o,int i, T l, T r){return fold(l,r);}
is like bypassing any 1 or 3 or higher and any 2 that does not start with an int.
Num : Successor | Zero. Zero = . Successor = "'"Fib = extends IDb. // function class to compute Fibonacci number Previous2 = "x "Num.
Previous2 combine(Successor nonempty, Previous2 p){
Previous2 h = new Previous2(p.get_x() + p.get_y(), p.get_x());
return h;
}
Previous2 combine(Zero i){
return new Previous2(1,0 );
}
which is is much more efficient than the recursive program.
RevPath(X.left, T tl) && RevPath(X.right, T tr) => StartPath(X, T fold(tl,tr)) T combine(X x, //RevPath(X.left, T tl) means: if there exists a path to X.left carrying object tl of type T.T tl, T tr)
StartPath(X,T t) means: there is a path starting at X carrying t of type T.
The class subgraph selected by the strategy provides the information to connect those paths.
Can we use Datalog to model DemeterF programs and reason about them? What kind of statements can we prove about the programs? Might lead to an algebraic approach to adaptive programming.
The code you write is invoked implicitly: Implicit invocation: http://en.wikipedia.org/wiki/Implicit_invocation. The function objects register for a traversal.
Programming using a flow.
Two kinds of traversal control.
Reasoning in terms of paths; connection to logic programming?
concrete.each { |thingy| visitor.visit thingy }
If visitors are easy in Ruby, what about a Ruby version of DemeterF?
Better Titles:
Removing Structural Accidental Complexity from Programs
Eliminate accessors: This does not capture what is important: we move from a push model to a pull model. In other words: from "talk to your friends" to "listen to your friends". We still talk about fields, but do it by position only.
Work related to parameterized class dictionaries:
@article{1040310,
author = {Haruo Hosoya and Alain Frisch and Giuseppe Castagna},
title = {Parametric polymorphism for XML},
journal = {SIGPLAN Not.},
volume = {40},
number = {1},
year = {2005},
issn = {0362-1340},
pages = {50--62},
doi = {http://doi.acm.org/10.1145/1047659.1040310},
publisher = {ACM},
address = {New York, NY, USA},
}
Life without getters