[asdf-devel] component-class for files selected on basis of *features*
Robert Goldman
rpgoldman at sift.info
Thu Dec 8 15:48:21 UTC 2011
On 12/7/11 Dec 7 -2:10 PM, Faré wrote:
> On Wed, Dec 7, 2011 at 14:55, Nikodemus Siivola
> <nikodemus at random-state.net> wrote:
>> I want to define a component class PORT-FILE, to be used like this:
>>
>> :components ((port-file "ccl" :when :ccl)
>> (port-file "clisp" :when :clisp)
>> (port-file "sbcl-x86" :when (and :sbcl :x86))
>> ...)
>>
>> The implementation I have adds AROUND methods for
>>
>> PERFORM (LOAD-OP PORT-FILE)
>> PERFORM (LOAD-SOURCE-OP PORT-FILE)
>> PERFORM (COMPILE-OP SOURCE-FILE)
>>
>> and does CALL-NEXT-METHOD only if the feature test passes -- which
>> seems to work well enough, but is there a better place to hook into?
>>
> That works indeed. I don't have any better option to offer,
> except maybe to make your featurization a mixin.
> Also if you rely on 2.018 or later, you can use asdf::featurep internally.
> You then need :and rather than cl:and, though.
Yes, this is a very readable approach for this. The built-in
alternative is the (IMO) very horrible alternative of adding feature
dependencies, and doing the conditionalization by handling dependency
failures. A simple :when is much more readable (again IMO).
If one was going to make featurization a mixin, one might want to modify
the syntax to :when-feature or something like that to make its meaning
even more clear to the reader.
Cheers,
r
More information about the asdf-devel
mailing list