[closer-devel] in-layer macro

Pascal Costanza pc at p-cos.net
Sat Apr 21 21:45:26 UTC 2007


Hi again,

At the ContextL tutorial at ILC'07, some people have asked for an  
additional convenience macro to ease writing ContextL code. The idea  
is to have a construct that "announce" a current layer, such that all  
subsequent class and method definitions are automatically associated  
with that layer, somewhat like the in-package macro in Common Lisp.

I have given some thought to this and see two possible directions.  
One would be to capture plain defclass and defmethod macros, and the  
other is to capture define-layered-class and define-layered-method  
macros. So for example, such a macro could look like this:

(in-layer some-layer
   (defclass person ()
     ((address :initarg :address :accessor address)))
   (defmethod do-it ((object person))
     (print (address object))))

...or it could look like that:

(in-layer some-layer
   (define-layered-class person ()
     ((address :initarg :address :layered-accessor address)))
   (define-layered-method do-it ((object person))
     (print (address object))))

In both cases, the expansion would look like this:

(progn
   (define-layered-class person :in-layer some-layer ()
     ((address :initarg :address :layered-accessor address)))
   (define-layered-method do-it :in-layer some-layer ((object person))
     (print (address object))))


The first variant of such an in-layer macro would ease moving  
existing CLOS code to ContextL, and the second variant would ease  
refactoring ContextL code, for example, to experiment with putting  
the same definitions in different layers. Of course, it would also be  
a possibility to do both, but I am hesitating a bit here because I  
would like to avoid feature bloat (and I smell some nasty corner  
cases here).

So far, I haven't been in need of such a convenience macro myself, so  
I don't really know which way to go. Does anyone have any opinions here?


Cheers,
Pascal

-- 
Pascal Costanza, mailto:pc at p-cos.net, http://p-cos.net
Vrije Universiteit Brussel, Programming Technology Lab
Pleinlaan 2, B-1050 Brussel, Belgium







More information about the closer-devel mailing list