1 ;;;; ls.scm --- functions for browsing modules
3 ;;;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
5 ;;;; This program is free software; you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation; either version 2, or (at your option)
8 ;;;; any later version.
10 ;;;; This program is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;;;; GNU General Public License for more details.
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with this software; see the file COPYING. If not, write to
17 ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 ;;;; Boston, MA 02111-1307 USA
21 (define-module (ice-9 ls)
22 :use-module (ice-9 common-list))
25 ;;; local-definitions-in root name
26 ;;; Returns a list of names defined locally in the named
27 ;;; subdirectory of root.
28 ;;; definitions-in root name
29 ;;; Returns a list of all names defined in the named
30 ;;; subdirectory of root. The list includes alll locally
31 ;;; defined names as well as all names inherited from a
32 ;;; member of a use-list.
34 ;;; A convenient interface for examining the nature of things:
36 ;;; ls . various-names
38 ;;; With just one argument, interpret that argument as the
39 ;;; name of a subdirectory of the current module and
40 ;;; return a list of names defined there.
42 ;;; With more than one argument, still compute
43 ;;; subdirectory lists, but return a list:
44 ;;; ((<subdir-name> . <names-defined-there>)
45 ;;; (<subdir-name> . <names-defined-there>)
49 (define-public (local-definitions-in root names)
50 (let ((m (nested-ref root names))
54 (module-for-each (lambda (k v) (set! answer (cons k answer))) m))
57 (define-public (definitions-in root names)
58 (let ((m (nested-ref root names)))
62 (cons (local-definitions-in m '())
63 (map (lambda (m2) (definitions-in m2 '()))
66 (define-public (ls . various-refs)
67 (and (pair? various-refs)
68 (if (cdr various-refs)
70 (cons ref (definitions-in (current-module) ref)))
72 (definitions-in (current-module) (car various-refs)))))
74 (define-public (lls . various-refs)
75 (and (pair? various-refs)
76 (if (cdr various-refs)
78 (cons ref (local-definitions-in (current-module) ref)))
80 (local-definitions-in (current-module) (car various-refs)))))
82 (define-public (recursive-local-define name value)
83 (let ((parent (reverse! (cdr (reverse name)))))
84 (and parent (make-modules-in (current-module) parent))
85 (local-define name value)))