File: loading.scm

package info (click to toggle)
sdc 1.0.8beta-8
  • links: PTS
  • area: contrib
  • in suites: slink
  • size: 1,400 kB
  • ctags: 874
  • sloc: lisp: 8,120; ansic: 967; makefile: 671; perl: 136; sh: 50
file content (79 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;{{{ module LOADING

(module loading
	(export
	 (load-silent file)
	 (require-library lib file)

	 (loading-verbosity . level)	; HACK to not import that variable

	 (v-load lib dest type)		; OBSOLETE
	 )
	(import
	 (memoize control "control.scm")
	 (files "files.scm")		; too much imported, bigloo doesn't
	                         ; like (path-find-files files "files.scm")

	 (message typeset "typeset.scm")
	 ))

;}}}
;{{{ Verbosity

(define *verbosely* 1)

(define (loading-verbosity . level)
  (if (pair? level)
      (set! *verbosely* (car level)))
  *verbosely*)

;}}}
;{{{ loading files at run time

(define (load-silent file)
  (with-output-to-file "/dev/null" (lambda () (load file))))

(define (load-*verbosely* fn)
  (if (> *verbosely* 2)
      (load fn)
      (load-silent fn)))

(define (load-library-*verbosely* lib file)
  (let ((fn (path-find-file lib file)))
    (if fn
	(load-*verbosely* fn)
	(begin (message 0 "No file in load path for " file)
	       #f))))

;}}}
;{{{ require-load

; Load a file from the *typeset-lib* path into mem
; RETURN:     what a load would have
; PARAMETER:  *verbosely*, level of verbosity
; ASIDE:      Memoize values; don't load it twice!

(define require-library-cache		; internal
					; bigloo allows reassign to
					; variables like that but not
					; to functions like the next
  (memoize
   (lambda (lib fn) (load-library-*verbosely* lib fn))
   (lambda (x y) #t)			; ignore lib path; HACK
   equal?))

(define (require-library lib file)
  (require-library-cache lib file))

;}}}
;{{{ v-load (OBSOLETE)

; load from lib/dest/type silent or not depending on *verbosely*

(define (v-load lib dest type)
  (let* ((fn (apply string-append 
	      (if (not (equal? dest "")) `(,dest "/" ,type ".scm")
	      `(type ".scm")))))
    (load-library-*verbosely* lib fn)))

;}}}