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?
Cheers,
-- Nikodemus
On Wed, Dec 7, 2011 at 14:55, Nikodemus Siivola nikodemus@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.
I wish I could say "just use XCVB" at this point, but XCVB isn't as portable or readily available as ASDF.
—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org Do not consider Collectivists as "sincere but deluded idealists". The proposal to enslave some men for the sake of others is not an ideal; brutality is not "idealistic," no matter what its purpose. Do not ever say that the desire to "do good" by force is a good motive. Neither power-lust nor stupidity are good motives. — Ayn Rand
On 12/7/11 Dec 7 -2:10 PM, Faré wrote:
On Wed, Dec 7, 2011 at 14:55, Nikodemus Siivola nikodemus@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