A more involved example - asdf Manual
Description: asdf Manual

Next: The defsystem grammar, Previous: The defsystem form, Up: Defining systems with defsystem

### 2.2 A more involved example

Let's illustrate some more involved uses of `defsystem` via a slightly convoluted example:

         (defsystem "foo"
           :version "1.0"
           :components ((:module "foo" :components ((:file "bar") (:file"baz")
                                                    (:file "quux"))
         	        :perform (compile-op :after (op c)
         			  (do-something c))
         		:explain (compile-op :after (op c)
         			  (explain-something c)))
                        (:file "blah")))

The method-form tokens need explaining: essentially, this part:

         	        :perform (compile-op :after (op c)
         			  (do-something c))
         		:explain (compile-op :after (op c)
         			  (explain-something c))

has the effect of

         (defmethod perform :after ((op compile-op) (c (eql ...)))
         	   (do-something c))
         (defmethod explain :after ((op compile-op) (c (eql ...)))
         	   (explain-something c))

where `...` is the component in question; note that although this also supports `:before` methods, they may not do what you want them to – a `:before` method on perform `((op compile-op) (c (eql ...)))` will run after all the dependencies and sub-components have been processed, but before the component in question has been compiled.