This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Apr 3, 2011, at 8:23 PM, Per Bothner wrote:
On 04/03/2011 04:56 PM, Jamison Hope wrote:I recently found myself wanting to conditionalize some code on the presence of a Java class. At first, I tried to see if I could have a module call (provide 'some-feature) only when this class was found, but then I realized it would be much simpler to modify the feature testing in IfFeature.java to recognize class names as a last resort. This has proven quite handy for me, letting me do something like:
(cond-expand (com.example.AClass ;; AClass is found in classpath, safe to use (define-simple-class MySubclass (com.example.AClass) ...)) (else (error "AClass not found.")))
It seems unlikely for some unrelated feature's name to exactly match a
fully-qualified class name, so I think this patch is pretty safe.
Seems reasonable - but idea occurs to me: Perhaps we should use the class: namespace prefix, as in:
http://www.gnu.org/software/kawa/Field-operations.html
Your example would be:
(cond-expand
(class:com.example.AClass ;; AClass is found in classpath, safe to use
(define-simple-class MySubclass (com.example.AClass) ...))
(else (error "AClass not found.")))
What do you think?
That's fine with me.
-- Jamison Hope The PTR Group www.theptrgroup.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |