[Top][All Lists]

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

Re: get all available symbols in scheme

From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: get all available symbols in scheme
Date: Tue, 14 Jun 2016 00:07:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

source liu <address@hidden> writes:

> Hi,
> glad to join the list
> I wonder if there is some way to dump all available symbols in current
> enviroment(something like “dir” in python), i think it is very useful when
> you are trying new modules
> I have tried the guile reference guide as well as google,but cant find any
> clue
> Any suggestion?
> great thanks

You can define something like:

    (define (display-module-interface module)
       (lambda (name variable)
         (let* ((name-length (string-length (symbol->string name)))
                (value (variable-ref variable))
                (documentation (object-stexi-documentation value)))
           (format #t "~a\n" name)
           (format #t "~a\n\n" (make-string name-length #\=))
           (format #t "Documentation:\n~a\n\n" documentation)
           (format #t "Value:\n~a\n\n\n" value)))
       (resolve-interface module)))

and then use it like this in the REPL:

    (display-module-interface '(rnrs bytevectors))

Comment out the line printing the value if you want...

One problem with this is that the stexi documentation may not look very
nice in plain text.

Another problem is that documentation is attached to objects in Guile,
rather than module/symbol combinations; this means, for example, if a
module defines a constant like O_APPEND which is bound to a number, it's
unclear where the documentation should be attached, since attaching it
to a number would be pretty weird.

A third problem is that we often lack documentation, sadly.


reply via email to

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