PMD with CLOS-style Method Combination

Hello All,
I recently happened upon the paper Prototypes with Multiple Dispatch by Salzman, and I decided to try implementing my own version of the PMD model he described in Scheme. As an extension to his model, I've added in support for CLOS style Method Combinations, such as the :after, :around, :before, and :standard dispatch orders.

Now, as near as I can tell, there haven't been any whitepapers written on the subject of combining PMD with Method Combinations, so I thought I'd ask you guys: Have you heard of anything like this? Even if you haven't, are there any pitfalls or oppertunties that you might be able to point out regarding this?


Edit: corrected ommision of the word "out".

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

To the best of my knowledge

To the best of my knowledge no one has really bothered trying to extend the model or toy with it extensively, although two people have expressed interest in the past.

The idea was that subjective dispatch was supposed to cover what stuff like around methods. Check out Dave Ungar's paper on "Us" for more extensive coverage. Other than that, I never really messed with method combination, and these days I'm reworking the model itself rather than extending it.

Method Combination is for

Method Combination is for the programmer's benefit than anything else. Just another mechanism to allow him to seperate his code into more reasonable chunks, so that closely related behavior is kept together, and behavior related but extrinsic to the actual task at hand can be kept on the side.

PMD and GC

One side effect of PMD is the creation of uncollectable garbage. Methods are pointed to by all participants in the dispatch, so short lived objects with specialized methods which also specialize on long lived objects will result in the specialized methods living as long as the long lived object; possibly long after the short lived object is gone and the method is useless.

This requires some change to a garbage collector to implement a kind of weakness such that these methods are collected when any participant is collected.

GC and PMD

I'll be the first to say that there's probably a better way to do PMD than I've worked out (linked hash-tables), however it's possible to keep from leaving around dangling references by making the dispatcher (the thing which decides what function to call for a given set of arguments) a first-class object. Then, you can keep it around only as long as needed, since it points at the objects, and not vice versa.
Your argument still stands for cases where you've got a long-lived dispatcher with arguments specialized on objects that should have otherwise been GC'd. The GC simply doesn't have enough info to realize that one of the arguments being out of scope or unused is sufficient cause to GC a particular lambda and it's associated references.

Paper Link

The actual paper is here, by the way.