Re: ASDF, readtables and with-operation
Richard M Kreuter <[email protected]>
| Newsgroups | gmane.lisp.cclan.general |
|---|---|
| Message-ID | <[email protected]> |
Gary King <[email protected]> writes: > I'm working with code that plays some tricks on the readtable. > Occasionally, this causes compilation of other systems to fail > because the altered readtable generally mucks things up. At the risk > of violating "you aren't going to need it", here is a suggested > patch. Assuming you haven't hosed the readtable too badly, can't you say (let ((*readtable* (copy-readtable nil))) (asdf:oos ... ...)) ? If someone wants to use a non-standard readtable by default when operating on asdf systems, this proposal would prevent that. (Support for doing strange things with the readtable is limited in most implementations, but I don't think that asdf ought to constrain things this way.) Additionally, note that OPERATE is /not/ invoked recursively to perform dependent operations on dependent systems. So the START-OPERATION and STOP-OPERATION functions you propose will only get called for an operation/system pair when these are explicitly OPERATE'd on, but not when the operation is performed on the system as part because of operation or system dependencies. That said, there are a couple systems in the wild from which you can generalize a technique for simulating auxiliary methods to be run before and around whole systems (either for side-effects, or for bindings). The recipe is to specialize the auxiliary method on the subclass of cl-source-file of which the system's files are instances, and to stash whatever information you need in the system itself. (To make this the site-wide default, unforuntately, requires either editing all your .asds, editing asdf.lisp, or using a MOP to add superclasses to asdf's standard classes.) Here, I think, is one way to simulate rebinding the readtable around system compilation and loading. It adds a readtable slot to system instances, and rebinds readtable to the system's readtable during compilation and loading of the system's files. (I've not tested this code, but I've got similar code to rearrange the package namespace around operations): -- (defpackage :not-asdf (:use :cl :asdf)) (in-package :not-asdf) (defclass readtable-rebinding-mixin () ()) (defclass readtable-holder () ((readtable :initarg :readtable :accessor readtable-of))) (defun component-system (component) (if (typep component 'system) component (component-system (component-parent component)))) (defmethod perform :around ((op compile-op) (comp readtable-rebinding-mixin)) (let* ((component-system (component-system comp)) (*readtable* (if (and (typep component-system 'readtable-holder) (slot-boundp component-system 'readtable)) (readtable-of component-system) *readtable*))) (call-next-method))) (defmethod perform :around ((op load-op) (comp readtable-rebinding-mixin)) (let* ((component-system (component-system comp)) (*readtable* (if (and (typep component-system 'readtable-aware-system) (slot-boundp component-system 'readtable)) (readtable-of component-system) *readtable*))) (call-next-method))) ;; If you're not interested in redefining asdf:system and ;; asdf:cl-source-file but want this behavior to be the site-wide ;; default, compose all the extension classes you like into named ;; classes, and then change your systems' .asd file to use those ;; classes, e.g., (defclass local-cl-source-file (readtable-rebinding-mixin ... cl-source-file) ()) (defclass local-system (readtable-holder ... system) ()) (defsystem <system-name> :class local-system :default-component-class local-cl-source-file ...) -- Hope that helps, RmK ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV