Skip to content

Commit

Permalink
Port Rules to MIT Scheme 11.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
axch committed Apr 11, 2022
1 parent 21f25c8 commit 4508ad9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
11 changes: 6 additions & 5 deletions load.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
;;;; Loading Rules

(define (self-relatively thunk)
(if (current-eval-unit #f)
(with-working-directory-pathname
(directory-namestring (current-load-pathname))
thunk)
(thunk)))
(let ((place (ignore-errors current-load-pathname)))
(if (pathname? place)
(with-working-directory-pathname
(directory-namestring place)
thunk)
(thunk))))

(define (load-relative filename)
(self-relatively (lambda () (load filename))))
Expand Down
4 changes: 2 additions & 2 deletions rules.scm
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@
(lambda (name required optional rest body)
name body
(append required
(if (null? optional) '() `(#!OPTIONAL ,@optional))
(if rest `(#!REST ,rest) '()))))
(if (null? optional) '() `(#!optional ,@optional))
(if rest `(#!rest ,rest) '()))))
(if (default-object? default-argl)
"No debugging information available for this procedure."
default-argl)))))
2 changes: 1 addition & 1 deletion simplifiers.scm
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
`(/ ,(simplify-sums
`(+ ,n
,(simplify-products
(* ,d ,(simplify-sums `(+ ,@a1 ,@a2))))))
`(* ,d ,(simplify-sums `(+ ,@a1 ,@a2))))))
,d)))))

(define quotient-of-sums->sum-of-quotients
Expand Down
23 changes: 8 additions & 15 deletions support/auto-compilation.scm
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,20 @@
(define (load-relative filename #!optional environment)
(self-relatively (lambda () (load filename environment))))

(define (compiled-code-type)
;; Trying to support the C backend
(if (lexical-unbound?
(nearest-repl/environment)
'compiler:compiled-code-pathname-type)
"com"
(compiler:compiled-code-pathname-type)))

;; The environment argument is the one to take macro definitions from
;; for sf.
(define (cf-conditionally filename #!optional environment)
(define (default-environment)
(if (current-eval-unit #f)
(current-load-environment)
(nearest-repl/environment)))
(let ((place (ignore-errors current-load-pathname)))
(if (pathname? place) ;; We are being loaded
(current-load-environment)
(nearest-repl/environment))))
(if (default-object? environment)
(set! environment (default-environment)))
(fluid-let ((sf/default-syntax-table environment))
(sf-conditionally filename))
(if (cf-seems-necessary? filename)
(compile-bin-file filename)))
(sf-conditionally filename)
(if (cf-seems-necessary? filename)
(compile-bin-file filename))))

(define (compiler-available?)
(not (lexical-unbound? (nearest-repl/environment) 'cf)))
Expand All @@ -69,7 +62,7 @@
(not (file-processed? filename "scm" "bin")))

(define (cf-seems-necessary? filename)
(not (file-processed? filename "bin" (compiled-code-type))))
(not (file-processed? filename "bin" "com")))

(define (load-compiled filename #!optional environment)
(if (compiler-available?)
Expand Down

0 comments on commit 4508ad9

Please sign in to comment.