Thursday, June 02, 2005

Deep ideas lurking in Object-Oriented Style, part I

Object-Oriented Style
Dan Friedman

A style such as CPS or what Dan describes as Object-Oriented Style, is roughly a design pattern begging for linguistic abstraction. He describes a tension between abstracting out the design pattern--which results in all the usual benefits of abstraction--and gaining a better understanding of the semantics of the style by writing it out explicitly.

This is a fundamental tension in language design. A linguistic abstraction that increases the expressive power of the language results in code that is more concise but that masks widespread (global) effects. One example he gives is the semantics of method calls: when is a method call static and when does it involve searching the inheritance chain? It's hard to tell when they just look like ordinary procedure invocation, but when you write the style explicitly, you can see how the method lookup is implemented.

Now, the expressiveness paper talks about true linguistic abstractions being those that aren't macro-expressible (albeit by a very specific definition of macro-expressibility), and Dan's paper implements the linguistic abstraction via macros. So this seems to muddy my point somewhat. But I think they still capture the spirit of global transformations, since they transform the entire class bodies.

(Interesting: I wonder if macro-defining macros allow you to make transformations that are not macro-expressible by Felleisen's formal definition.)

No comments: