summaryrefslogtreecommitdiffstats
path: root/elk.init
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:31 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:31 -0800
commit5145dd3aa0c02c9fc496d1432fc4410674206e1d (patch)
tree540afc30c51da085f5bd8ec3f4c89f6496e7900d /elk.init
parent8466d8cfa486fb30d1755c4261b781135083787b (diff)
downloadslib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.tar.gz
slib-5145dd3aa0c02c9fc496d1432fc4410674206e1d.zip
Import Upstream version 3a2upstream/3a2
Diffstat (limited to 'elk.init')
-rw-r--r--elk.init160
1 files changed, 111 insertions, 49 deletions
diff --git a/elk.init b/elk.init
index 13fde42..f495e5c 100644
--- a/elk.init
+++ b/elk.init
@@ -37,7 +37,7 @@
;;; implementation reside.
(define (implementation-vicinity)
(case (software-type)
- ((UNIX) "/usr/local/lib/elk/runtime/scm/")
+ ((UNIX) "/usr/share/elk/")
((VMS) "scheme$src:")
((MS-DOS) "C:\\scheme\\")))
@@ -70,75 +70,149 @@
home
(string-append home "/")))
(else home)))))
+;@
+(define in-vicinity string-append)
+;@
+(define (user-vicinity)
+ (case (software-type)
+ ((VMS) "[.]")
+ (else "")))
-;;; *features* should be set to a list of symbols describing features
-;;; of this implementation. Suggestions for features are:
+(define *load-pathname* #f)
+;@
+(define vicinity:suffix?
+ (let ((suffi
+ (case (software-type)
+ ((AMIGA) '(#\: #\/))
+ ((MACOS THINKC) '(#\:))
+ ((MS-DOS WINDOWS ATARIST OS/2) '(#\\ #\/))
+ ((NOSVE) '(#\: #\.))
+ ((UNIX COHERENT PLAN9) '(#\/))
+ ((VMS) '(#\: #\]))
+ (else
+ (slib:warn "require.scm" 'unknown 'software-type (software-type))
+ "/"))))
+ (lambda (chr) (and (memv chr suffi) #t))))
+;@
+(define (pathname->vicinity pathname)
+ (let loop ((i (- (string-length pathname) 1)))
+ (cond ((negative? i) "")
+ ((vicinity:suffix? (string-ref pathname i))
+ (substring pathname 0 (+ i 1)))
+ (else (loop (- i 1))))))
+(define (program-vicinity)
+ (if *load-pathname*
+ (pathname->vicinity *load-pathname*)
+ (slib:error 'program-vicinity " called; use slib:load to load")))
+;@
+(define sub-vicinity
+ (case (software-type)
+ ((VMS) (lambda
+ (vic name)
+ (let ((l (string-length vic)))
+ (if (or (zero? (string-length vic))
+ (not (char=? #\] (string-ref vic (- l 1)))))
+ (string-append vic "[" name "]")
+ (string-append (substring vic 0 (- l 1))
+ "." name "]")))))
+ (else (let ((*vicinity-suffix*
+ (case (software-type)
+ ((NOSVE) ".")
+ ((MACOS THINKC) ":")
+ ((MS-DOS WINDOWS ATARIST OS/2) "\\")
+ ((UNIX COHERENT PLAN9 AMIGA) "/"))))
+ (lambda (vic name)
+ (string-append vic name *vicinity-suffix*))))))
+;@
+(define (make-vicinity <pathname>) <pathname>)
+;@
+(define with-load-pathname
+ (let ((exchange
+ (lambda (new)
+ (let ((old *load-pathname*))
+ (set! *load-pathname* new)
+ old))))
+ (lambda (path thunk)
+ (let* ((old (exchange path))
+ (val (thunk)))
+ (exchange old)
+ val))))
+
+;;@ *FEATURES* is a list of symbols naming the (SLIB) features
+;;; initially supported by this implementation.
(define *features*
'(
source ;can load scheme source files
- ;(slib:load-source "filename")
+ ;(SLIB:LOAD-SOURCE "filename")
compiled ;can load compiled files
- ;(slib:load-compiled "filename")
+ ;(SLIB:LOAD-COMPILED "filename")
+ vicinity
+ srfi-59
;; Scheme report features
+ ;; R5RS-compliant implementations should provide all 9 features.
-; r5rs ;conforms to
-; eval ;R5RS two-argument eval
-; values ;R5RS multiple values
-; dynamic-wind ;R5RS dynamic-wind
-; macro ;R5RS high level macros
+;;; r5rs ;conforms to
+;;; eval ;R5RS two-argument eval
+;;; values ;R5RS multiple values
+;;; dynamic-wind ;R5RS dynamic-wind
+;;; macro ;R5RS high level macros
delay ;has DELAY and FORCE
multiarg-apply ;APPLY can take more than 2 args.
-; char-ready?
-; rationalize
- rev4-optional-procedures ;LIST-TAIL, STRING->LIST,
- ;LIST->STRING, STRING-COPY,
- ;STRING-FILL!, LIST->VECTOR,
- ;VECTOR->LIST, and VECTOR-FILL!
+;;; char-ready?
+ rev4-optional-procedures ;LIST-TAIL, STRING-COPY,
+ ;STRING-FILL!, and VECTOR-FILL!
+
+ ;; These four features are optional in both R4RS and R5RS
+
+ multiarg/and- ;/ and - can take more than 2 args.
+;;; rationalize
+ transcript ;TRANSCRIPT-ON and TRANSCRIPT-OFF
+;;; with-file ;has WITH-INPUT-FROM-FILE and
+ ;WITH-OUTPUT-TO-FILE
r4rs ;conforms to
ieee-p1178 ;conforms to
-; r3rs ;conforms to
+;;; r3rs ;conforms to
rev2-procedures ;SUBSTRING-MOVE-LEFT!,
;SUBSTRING-MOVE-RIGHT!,
;SUBSTRING-FILL!,
;STRING-NULL?, APPEND!, 1+,
;-1+, <?, <=?, =?, >?, >=?
-; object-hash ;has OBJECT-HASH
+;;; object-hash ;has OBJECT-HASH
- multiarg/and- ;/ and - can take more than 2 args.
-; with-file ;has WITH-INPUT-FROM-FILE and
- ;WITH-OUTPUT-TO-FILE
- transcript ;TRANSCRIPT-ON and TRANSCRIPT-OFF
-; ieee-floating-point ;conforms to IEEE Standard 754-1985
+ full-continuation ;can return multiple times
+;;; ieee-floating-point ;conforms to IEEE Standard 754-1985
;IEEE Standard for Binary
;Floating-Point Arithmetic.
- full-continuation ;can return multiple times
;; Other common features
-; srfi ;srfi-0, COND-EXPAND finds all srfi-*
+;;; srfi ;srfi-0, COND-EXPAND finds all srfi-*
sicp ;runs code from Structure and
;Interpretation of Computer
;Programs by Abelson and Sussman.
-; defmacro ;has Common Lisp DEFMACRO
-; record ;has user defined data structures
+;;; defmacro ;has Common Lisp DEFMACRO
+;;; record ;has user defined data structures
string-port ;has CALL-WITH-INPUT-STRING and
;CALL-WITH-OUTPUT-STRING
sort
-; pretty-print
-; object->string
+;;; pretty-print
+;;; object->string
format ;Common-lisp output formatting
-; trace ;has macros: TRACE and UNTRACE
-; compiler ;has (COMPILER)
-; ed ;(ED) is editor
+;;; trace ;has macros: TRACE and UNTRACE
+;;; compiler ;has (COMPILER)
+;;; ed ;(ED) is editor
system ;posix (system <string>)
getenv ;posix (getenv <string>)
program-arguments ;returns list of strings (argv)
-; current-time ;returns time in seconds since 1/1/1970
+;;; current-time ;returns time in seconds since 1/1/1970
+
+ ;; Implementation Specific features
+
))
;------------
@@ -278,18 +352,7 @@
;;; If your implementation provides R4RS macros:
;(define macro:eval slib:eval)
;(define macro:load load)
-
-(define (slib:eval-load <pathname> evl)
- (if (not (file-exists? <pathname>))
- (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
- (call-with-input-file <pathname>
- (lambda (port)
- (let ((old-load-pathname *load-pathname*))
- (set! *load-pathname* <pathname>)
- (do ((o (read port) (read port)))
- ((eof-object? o))
- (evl o))
- (set! *load-pathname* old-load-pathname)))))
+;; slib:eval-load definition moved to "require.scm"
(define slib:warn
(lambda args
@@ -325,10 +388,8 @@
;(define (-1+ n) (+ n -1))
;(define 1- -1+)
-(define in-vicinity string-append)
-
;;; Define SLIB:EXIT to be the implementation procedure to exit or
-;;; return if exitting not supported.
+;;; return if exiting not supported.
(define slib:exit
(lambda args
(exit (cond ((null? args) 0)
@@ -355,7 +416,8 @@
(let ((primitive-load load))
(lambda (<pathname> . rest)
(let ((env (if (null? rest) (list (global-environment)) rest)))
- (apply primitive-load <pathname> env)))))
+ (apply primitive-load (string-append <pathname> (scheme-file-suffix))
+ env)))))
;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
;;; by compiling "foo.scm" if this implementation can compile files.