[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RE: succinctness = power

Avi Bryant wrote:

> Many patterns (design and otherwise) don't lend themselves well to being
> captured by lisp macros and similar mechanisms, which are constrained to
> have purely local effects - that is, they can only transform source code
> inside their lexical scope.  

Indeed.  Steve Reiss at Brown built a very nice system for treating
patterns as constraints over a source program.  I'll let the abstract
speak for itself:

  This paper describes the basis for a suite of tools that let the
  programmer work in terms of design patterns and source code
  simultaneously. It first introduces a language for defining design
  patterns. This language breaks a pattern down into elements and
  constraints over a program database of structural and semantic
  information. The language supports both creating new program elements
  when a pattern is created or modified and generating source code for
  these new elements.

  The paper next describes tools for working with patterns. These tools
  let the user identify and create instances of patterns in the source
  code. Once patterns are so identified they can be saved in a library
  of patterns that accompanies the system and the patterns can be
  verified, maintained as the source evolves, and edited to modify the



>			       Their composability is also quite limited (a
> good example of this is the various CL macros out there that wrap
> defclass; how do you use features from two of them at once?).

I saw the text in your related work section (which, incidentally,
seems to have a pretty warped understanding of prior work, but we can
take that off-line), but wasn't impressed by section 4.4.  I don't
actually believe this will scale.  (Two different people write macros;
what annotations can they possibly provide?)  Indeed, the idea you
propose there has been explored in detail for several years by Don
Batory, and I think his findings lend considerable weight to my claim.
The naive, purely syntactic solution isn't enough.

> Andrew Catton and I developed a tool called ELIDE last year which allows
> macro-like transformations on Java that don't have these limitations:
> parameterized annotations can be attached to any source construct, which
> trigger transformations whose scope is limited only by the developer's
> good sense.  

This was also possible in the now-defunct McMicMac macro (sorry,
"generative programming" is the fiscally correct term these days)
system that lay under DrScheme.

The point here is simply that you can have an extended notion of a
macro system that doesn't suffer from this limitation.  The real
problem here isn't this, but rather in making composition sensible.