[cffi-devel] define-foreign-library behavior
Hello, On OS-X, this works: (define-foreign-library libc (t (:default "libc"))) (use-foreign-library libc) But this doesn't: (define-foreign-library libc (t (:or "libc" "libc.so.6"))) (use-foreign-library libc) This seems to be because load-foreign-library doesn't attempt to guess the appropriate suffix for the library name when used with :or. This is the documented behavior but it could be a little confusing since the second example appears to the naive (like me) to be a super- set of the first example. Also: (define-foreign-library libc (:unix (:or "libc.so.6")) (t (:default "libc"))) (use-foreign-library libc) Doesn't work since OS-X is unix, but not linux. Maybe after failing on the specific case (i.e. unix), it could fall back to the general case? I could try and provide patches for one or both of these behaviors if people think that this would be an improvement. best, -Hazen
On 2006-maj-13, at 20:01, hbabcockos1@mac.com wrote:
(t (:default "libc"))) [vs] (t (:or "libc" "libc.so.6"))) [...] the second example appears to the naive (like me) to be a super-set of the first example.
You want: (:or (:default "libc") "libc.so.6)
Also: (define-foreign-library libc (:unix (:or "libc.so.6")) (t (:default "libc"))) (use-foreign-library libc)
Doesn't work since OS-X is unix, but not linux. Maybe after failing on the specific case (i.e. unix), it could fall back to the general case?
I suppose falling back to other clauses in a COND-like fashion wouldn't hurt. -- Luís Oliveira http://student.dei.uc.pt/~lmoliv/
On May 13, 2006, at 10:20 PM, Luís Oliveira wrote:
On 2006-maj-13, at 20:01, hbabcockos1@mac.com wrote:
(t (:default "libc"))) [vs] (t (:or "libc" "libc.so.6"))) [...] the second example appears to the naive (like me) to be a super- set of the first example.
You want: (:or (:default "libc") "libc.so.6)
Thanks! My apologies for not realizing that you could combine things in this way. -Hazen
On Sat, 2006-05-13 at 15:01 -0400, hbabcockos1@mac.com wrote:
(define-foreign-library libc (t (:default "libc"))) (use-foreign-library libc)
But this doesn't:
(define-foreign-library libc (t (:or "libc" "libc.so.6"))) (use-foreign-library libc)
This seems to be because load-foreign-library doesn't attempt to guess the appropriate suffix for the library name when used with :or. This is the documented behavior but it could be a little confusing since the second example appears to the naive (like me) to be a super- set of the first example.
Consider instead that library spec clauses have an evaluation rule that supports composition of useful, yet orthogonal operators. :OR and :DEFAULT behavior should not intersect in such a scheme.
Also: (define-foreign-library libc (:unix (:or "libc.so.6")) (t (:default "libc"))) (use-foreign-library libc)
Doesn't work since OS-X is unix, but not linux. Maybe after failing on the specific case (i.e. unix), it could fall back to the general case?
I won't state a preference on this, except that the current behavior seems chosen to be much like that of COND, CASE, and other such CL forms with test-expr clauses. -- Stephen Compall http://scompall.nocandysw.com/blog
participants (4)
-
Hazen Babcock
-
hbabcockos1@mac.com
-
Luís Oliveira
-
Stephen Compall