[metacopy-devel] Re: another place where contextl is very handy

Pascal Costanza pc at p-cos.net
Sun Oct 8 10:35:15 UTC 2006


On 7 Oct 2006, at 11:42, Attila Lendvai wrote:

>
> Pascal, here's another good use of contextl:
>
> http://common-lisp.net/pipermail/metacopy-devel/2006-October/ 
> thread.html#0
>
> only 3 mails, but in summary: there's a generic copy-thing protocol  
> which is a one-fits-all copy protocol. but one could easily build  
> some macrology on top of it for customized copy protocols that are  
> the extension/customizations of the generic copy-thing protocol and/ 
> or other copy protocols.

Hm, of course I like it when people find uses for ContextL. However,  
wouldn't a separation into different copy functions be sufficient  
here? (So, having separate functions like deep-copy, shallow-copy,  
structure-copy, and so on?)

Note: I don't enough about metacopy, so it's very likely that I am  
missing something here.

> besides the usefulness i think this could be a very good  
> demonstration of contextl. we need this, so i'll either work on  
> metacopy to integrate with contextl (not likely, unless i find a  
> way to integrate metacopy and contextl so that the contextl  
> dependency is optional) or create a standalone metacopy-like  
> package that depends on contextl.

Making ContextL optional is not straightforward because ContextL  
requires generic functions to be of the right metaclass, i.e.,  
layered-function. In principle, CLOS specifices that you can change  
the metaclass of a generic function via change-class, but I am aware  
of only one CL implementation that actually implements this (that  
would be clisp), and I have doubts that this is a good idea in the  
first place.

One idea would be to have a common entry point, roughly like this:

(defun copy (&rest args)
   (declare (dynamic-extent args))
   #+layered-copy (apply #'layered-copy args)
   #-layered-copy (apply #'generic-copy args))

With the right optimization settings, this shouldn't be too costly.

> hoping you find this interesting,

Yep. ;)


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




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/metacopy-devel/attachments/20061008/ab59ca54/attachment.html>


More information about the metacopy-devel mailing list