File: start.scm

package info (click to toggle)
scsh 0.5.1-2
  • links: PTS
  • area: non-free
  • in suites: potato, slink
  • size: 6,540 kB
  • ctags: 8,656
  • sloc: lisp: 39,346; ansic: 13,466; sh: 1,669; makefile: 624
file content (67 lines) | stat: -rw-r--r-- 2,133 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
; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees.  See file COPYING.


(define (start structs-to-open)
  (lambda (structs-thunk)
    (usual-resumer
     (lambda (arg)
       (let* ((structs (structs-thunk))
	      (b (make-built-in-structures structs)))
	 (initialize-interaction-environment! b)
	 (with-interaction-environment
	     (make-initial-package b structs-to-open)
	   (lambda ()
	     (command-processor (cond ((assq 'usual-commands structs)
				       => (lambda (z)
					    (structure-package (cdr z))))
				      (else #f))
				arg))))))))

; The structs argument is an a-list of (name . structure), as computed
; by the expression returned by reify-structures.

(define (make-built-in-structures structs)
  (let* ((p (make-simple-package '() #f #f 'built-in-structures))
	 (s (make-structure p
		  (lambda ()
		    (make-simple-interface
		       #f			;name
		       (cons 'built-in-structures (map car structs))))
		  'built-in-structures)))
    (for-each (lambda (name+struct)
		(environment-define! p
				     (car name+struct)
				     (cdr name+struct)))
	      structs)
    (environment-define! p 'built-in-structures s)
    s))

(define (initialize-interaction-environment! built-in-structures)
  (let ((scheme (*structure-ref built-in-structures 'scheme))
	(tower (make-tower built-in-structures 'interaction)))
    (set-interaction-environment!
     (make-simple-package (list scheme) #t tower 'interaction))

    (set-scheme-report-environment!
     5
     (make-simple-package (list scheme) #t tower 'r5rs))))

; Intended for bootstrapping the command processor.

(define (make-initial-package built-in-structures structs-to-open)
  (let ((p (make-simple-package
	    (cons built-in-structures
		  (map (lambda (name)
			 (*structure-ref built-in-structures name))
		       structs-to-open))
	    eval
	    (make-tower built-in-structures 'initial)
	    'initial)))
    (environment-define! p 'built-in-structures built-in-structures)
    p))

(define (make-tower built-in-structures id)
  (make-reflective-tower eval
			 (list (*structure-ref built-in-structures
					       'scheme))
			 id))