[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is (catch #t (lambda () (use-modules (xxx))) ...) OK?

From: Marius Vollmer
Subject: Re: Is (catch #t (lambda () (use-modules (xxx))) ...) OK?
Date: 13 Apr 2001 20:35:38 +0200
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Rob Browning <address@hidden> writes:

> Is this an effective way to test for the existence of a module, and if
> so, will a second (use-modules ...)  be required to actually get an
> effect on the top-level envt?  i.e.
>   (if (catch #t (lambda () (use-modules (xxx)) #t)
>                 (lambda (key . args) #f))
>     (use-modules xxx)
>     (do-something-else ...))

This does not work since `use-modules' can only be used at the
top-level.  You always get an error, which is caught, and so you
always return `#f', even for existing modules.

I think the closest thing to what you want is `resolve-interface':

    (resolve-interface '(ice-9 common-list))
    => #<interface (ice-9 common-list) 80848c0>

    (resolve-interface '(ice-9 bla))
    => #f

Thus, you could do

    (if (resolve-interface '(xxx))
      (use-modules (xxx))
      (do-something-else ...))

The `use-modules' is at the top-level when the `if' is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]