I finally discovered a way to make definitions depending on whether a
certain library is available:
(define make-engine
(call/cc
(lambda (k)
(with-exception-handler
(lambda (x) (k #f))
(lambda () (eval 'make-engine (environment '(scheme))))))))
(define-syntax if-engines
(lambda (o)
(define make-engine
(call/cc
(lambda (k)
(with-exception-handler
(lambda (x) (k #f))
(lambda () (eval 'make-engine (environment '(scheme))))))))
(syntax-case o ()
((_ c) #'(if-engines c (if #f #f)))
((_ c a) (if make-engine #'c #'a)))))
I then go on to use if-engines like this: (if-engines (begin some
definitions which require make-engine) (begin alternative
definitions)).
As you can see I had to define make-engine twice, once for syntax and
once for runtime. I know there's a nonstandard way to define it only
once: (meta define make-engine ...) (actually, I'm not sure whether
you still have to define it for runtime if you do that...). Is there
another portable solution than defining it twice which would still let
me put all my code in one file?