(ice-9 ls)

Jim Blandy (jimb@red-bean.com)
Wed, 22 Oct 1997 11:59:53 -0400

>Could someone please give me a few examples of how to use the
>procedures `ls' and `definitions-in' from "ice-9/ls.scm".
>(They don't seem to be documented yet in guile-doc-971015.)
>
>In fact I don't understand what a "subdirectory" of a module is. Does
>it mean a module "used" by the module?

If you've got a module with a name like (ice-9 regex), then regex is a
subdirectory of ice-9. If I understand it correctly, Tom Lord's
original plan involved placing all kinds of resources in a
hierarchical namespace, like Plan 9 --- widgets, network connections,
etc. There's a global variable called `app', whose value is a module
object containing bindings for other modules, or random objects. At
the moment, it's only used for modules.

I don't like this idea; Plan 9 needs to use filenames so you can pass
references to resources between shell scripts, etc. But Guile's app
namespace is local to one process, and in Scheme, you've got real
pointers; why not pass objects around directly? So I consider this
stuff vestigial.

The code also assumes (eq? '() #f); I've included a patch for that
below, although it doesn't make a huge difference.

$ guile
guile> (use-modules (ice-9 ls))
guile> (ls '(app))
(((app) modules))
guile> (ls '(app modules))
(((app modules) guile ice-9))
guile> (ls '(app modules ice-9))
(((app modules ice-9) debug common-list regex session ls))
guile> (ls '(app modules ice-9 regex))
(((app modules ice-9 regex) %module-public-interface match:suffix
string-match match:start regexp-substitute/global regexp-quote
match:prefix regexp-substitute match:substring match:string
regexp-match? match:end match:count car abort-hook
module-public-interface debug-enable debug-options module-for-each
eval module? module-ref define-private nested-ref map builtin-variable
add-hook! pair? variable-set! cons module-uses module-add! set! quote
not memq let lambda if define-public define cond current-module begin
and module-define! module-variable null? read-enable cdr))
guile> (ls '(app modules ice-9 regex %module-public-interface))
(((app modules ice-9 regex %module-public-interface)
match:count match:end regexp-match? match:string match:substring
regexp-substitute match:prefix regexp-quote regexp-substitute/global
match:start string-match match:suffix))
guile>

Index: ls.scm
===================================================================
RCS file: /u/src/master/guile-core/ice-9/ls.scm,v
retrieving revision 1.1
diff -c -c -b -F'^(' -r1.1 ls.scm
*** ls.scm 1997/09/30 17:16:51 1.1
--- ls.scm 1997/10/22 15:44:35
***************
*** 46,52 ****
(module-uses m)))))))

(define-public (ls . various-refs)
! (and various-refs
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (definitions-in (current-module) ref)))
--- 46,52 ----
(module-uses m)))))))

(define-public (ls . various-refs)
! (and (pair? various-refs)
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (definitions-in (current-module) ref)))
***************
*** 54,60 ****
(definitions-in (current-module) (car various-refs)))))

(define-public (lls . various-refs)
! (and various-refs
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (local-definitions-in (current-module) ref)))
--- 54,60 ----
(definitions-in (current-module) (car various-refs)))))

(define-public (lls . various-refs)
! (and (pair? various-refs)
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (local-definitions-in (current-module) ref)))