File: eval.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 (68 lines) | stat: -rw-r--r-- 1,719 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
; Copyright (c) 1993, 1994 Richard Kelsey and Jonathan Rees.  See file COPYING.

; Added really-eval-scanned-forms, which gives you noise control.
; 	-Olin 6/95.

; This file contains things that tie together the compiler and the
; run-time system.


; EVAL

(define (eval form p)
  (compile-and-run-forms (list form) p #f
			 (lambda (template)
			   (invoke-template template p))
			 #f))

; LOAD-INTO - load file into package.

(define (load-into filename p)
  (compile-and-run-file filename p
			(lambda (template)
			  (invoke-template template p))
			(current-output-port)))

; For scsh.

(define (load-quietly from p)
  ((if (string? from) compile-and-run-file compile-and-run-port)
   from p
   (lambda (template)
     (invoke-template template p))
   #f))

; Evaluate forms as if they came from the given file.

(define (eval-from-file forms p filename)
  (compile-and-run-forms forms p filename
			 (lambda (template)
			   (invoke-template template p))
			 (current-output-port)))

; For ENSURE-LOADED.

(define (eval-scanned-forms forms p filename)
  (really-eval-scanned-forms forms p filename (current-output-port)))

(define (really-eval-scanned-forms forms p filename noise-port)
  (compile-and-run-scanned-forms forms p filename
				 (lambda (template)
				   (invoke-template template p))
				 noise-port))

(define (invoke-template template p)
  (invoke-closure (make-closure template (package-uid p))))


; LOAD

(define (load filename . package-option)
  (let ((p (if (null? package-option)
	       (interaction-environment)
	       (car package-option))))
    ;; (with-interaction-environment p
      ;; (lambda ()
	(noting-undefined-variables p
	  (lambda ()
	    (load-into filename p)))));; ))