[asdf-devel] loading platform-dependent code

Robert Goldman rpgoldman at sift.info
Sun Jan 24 20:28:37 UTC 2010


On 1/24/10 Jan 24 -2:02 PM, Tamas Papp wrote:
> Hi,
> 
> I am the author of the cl-cairo2 library.  Cairo itself is a graphics
> library, and my library provides a Lisp interface.
> 
> Some of the features (eg drawing in X11, Windows or Quartz) are
> platform dependent.  Currently, the approach of cl-cairo2 is to
> provide extra system definitions for these, eg an X11 user would load
> the systems cl-cairo2 and cl-cairo2-x11 manually.  I am wondering if
> there is a better way to do platform-dependent loading.
> 
> The solution I was thinking of was to try loading the platform
> dependent shared C libraries using CFFI, and set some flag (or push
> something to *features*) if they succeed, but if they fail, capture
> the condition with handler-case and just proceed with a warning.  Then
> I could load platform-dependent code conditionally on this --- but I
> don't know how to do that in ASDF.
> 
> Please tell me what is the "right way" to do these things (ie stuff
> that I put in features).  Examples of libraries that load
> platform-dependent code conditionally with ASDF would also help.

You might try looking at CL-SQL, which has multiple backends.  Or McCLIM.

I believe that the :if-component-dep-fails argument was intended to be
used for this --- you specify a dependency on a feature together with a
failure strategy that moves on to the next alternative --- but this is
not adequately documented, and I've never found it to be a particularly
clear way of specifying a behavior.  I'm not sure why having a feature
dependency combined with a dependency failure handler is a more happy
substitute for just using #+

Christophe Rhodes has, I believe, on occasion pointed to an example that
uses this mechanism, but I don't have a good pointer to it.

If you can find a good solution to this problem, please post it to the
list, and I will try to see that it gets into the manual.

cheers,
r




More information about the asdf-devel mailing list