home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / programmation / scm4e2.arc / !Scm / slibdocs / Template < prev   
Text File  |  1994-11-27  |  8KB  |  264 lines

  1. ;"Template.scm" configuration template of *features* for Scheme    -*-scheme-*-
  2. ; Copyright (C) 1991, 1992, 1993 Aubrey Jaffer.
  3. ;
  4. ;Permission to copy this software, to redistribute it, and to use it
  5. ;for any purpose is granted, subject to the following restrictions and
  6. ;understandings.
  7. ;
  8. ;1.  Any copy made of this software must include this copyright notice
  9. ;in full.
  10. ;
  11. ;2.  I have made no warrantee or representation that the operation of
  12. ;this software will be error-free, and I am under no obligation to
  13. ;provide any services, by way of maintenance, update, or otherwise.
  14. ;
  15. ;3.  In conjunction with products arising from the use of this
  16. ;material, there shall be no use of my name in any advertising,
  17. ;promotional, or sales literature without prior written consent in
  18. ;each case.
  19.  
  20. ;;; (software-type) should be set to the generic operating system type.
  21. ;;; UNIX, VMS, MACOS, AMIGA and MSDOS are supported.
  22.  
  23. (define (software-type) 'UNIX)
  24.  
  25. ;;; (scheme-implementation-type) should return the name of the scheme
  26. ;;; implementation loading this file.
  27.  
  28. (define (scheme-implementation-type) 'Template)
  29.  
  30. ;;; (scheme-implementation-version) should return a string describing
  31. ;;; the version the scheme implementation loading this file.
  32.  
  33. (define (scheme-implementation-version) "?")
  34.  
  35. ;;; (implementation-vicinity) should be defined to be the pathname of
  36. ;;; the directory where any auxillary files to your Scheme
  37. ;;; implementation reside.
  38.  
  39. (define (implementation-vicinity)
  40.   (case (software-type)
  41.     ((UNIX)     "/usr/local/src/scheme/")
  42.     ((VMS)    "scheme$src:")
  43.     ((MSDOS)    "C:\\scheme\\")))
  44.  
  45. ;;; (library-vicinity) should be defined to be the pathname of the
  46. ;;; directory where files of Scheme library functions reside.
  47.  
  48. (define library-vicinity
  49.   (let ((library-path
  50.      (or
  51.       ;; Use this getenv if your implementation supports it.
  52.       (getenv "SCHEME_LIBRARY_PATH")
  53.       ;; Use this path if your scheme does not support GETENV
  54.       ;; or if SCHEME_LIBRARY_PATH is not set.
  55.       (case (software-type)
  56.         ((UNIX) "/usr/local/lib/slib/")
  57.         ((VMS) "lib$scheme:")
  58.         ((MSDOS) "C:\\SLIB\\")
  59.         (else "")))))
  60.     (lambda () library-path)))
  61.  
  62. ;;; *FEATURES* should be set to a list of symbols describing features
  63. ;;; of this implementation.  Suggestions for features are:
  64.  
  65. (define *features*
  66.       '(
  67.     source                ;can load scheme source files
  68.                     ;(slib:load-source "filename")
  69. ;    compiled            ;can load compiled files
  70.                     ;(slib:load-compiled "filename")
  71. ;    rev4-report            ;conforms to
  72. ;    rev3-report            ;conforms to
  73. ;    ieee-p1178            ;conforms to
  74. ;    sicp                ;runs code from Structure and
  75.                     ;Interpretation of Computer
  76.                     ;Programs by Abelson and Sussman.
  77. ;    rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  78.                     ;LIST->STRING, STRING-COPY,
  79.                     ;STRING-FILL!, LIST->VECTOR,
  80.                     ;VECTOR->LIST, and VECTOR-FILL!
  81. ;    rev3-procedures            ;LAST-PAIR, T, and NIL
  82. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  83.                     ;SUBSTRING-MOVE-RIGHT!,
  84.                     ;SUBSTRING-FILL!,
  85.                     ;STRING-NULL?, APPEND!, 1+,
  86.                     ;-1+, <?, <=?, =?, >?, >=?
  87. ;    multiarg/and-            ;/ and - can take more than 2 args.
  88. ;    multiarg-apply            ;APPLY can take more than 2 args.
  89. ;    rationalize
  90. ;    delay                ;has DELAY and FORCE
  91. ;    with-file            ;has WITH-INPUT-FROM-FILE and
  92.                     ;WITH-OUTPUT-FROM-FILE
  93. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  94.                     ;CALL-WITH-OUTPUT-STRING
  95. ;    transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  96. ;    char-ready?
  97. ;    macro                ;has R4RS high level macros
  98. ;    defmacro            ;has Common Lisp DEFMACRO
  99. ;    eval                ;SLIB:EVAL is single argument eval
  100. ;    record                ;has user defined data structures
  101. ;    values                ;proposed multiple values
  102. ;    dynamic-wind            ;proposed dynamic-wind
  103. ;    ieee-floating-point        ;conforms to
  104.     full-continuation        ;can return multiple times
  105. ;    object-hash            ;has OBJECT-HASH
  106.  
  107. ;    sort
  108. ;    queue                ;queues
  109. ;    pretty-print
  110. ;    object->string
  111. ;    format
  112. ;    trace                ;has macros: TRACE and UNTRACE
  113. ;    compiler            ;has (COMPILER)
  114. ;    ed                ;(ED) is editor
  115. ;    system                ;posix (system <string>)
  116.     getenv                ;posix (getenv <string>)
  117. ;    program-arguments        ;returns list of strings (argv)
  118. ;    Xwindows            ;X support
  119. ;    curses                ;screen management package
  120. ;    termcap                ;terminal description package
  121. ;    terminfo            ;sysV terminal description
  122. ;    current-time            ;returns time in seconds since 1/1/1970
  123.     ))
  124.  
  125. ;;; (OUTPUT-PORT-WIDTH <port>)
  126. (define (output-port-width . arg) 79)
  127.  
  128. ;;; (OUTPUT-PORT-HEIGHT <port>)
  129. (define (output-port-height . arg) 24)
  130.  
  131. ;;; (CURRENT-ERROR-PORT)
  132. (define current-error-port
  133.   (let ((port (current-output-port)))
  134.     (lambda () port)))
  135.  
  136. ;;; (TMPNAM) makes a temporary file name.
  137. (define tmpnam (let ((cntr 100))
  138.          (lambda () (set! cntr (+ 1 cntr))
  139.              (string-append "slib_" (number->string cntr)))))
  140.  
  141. ;;; (FILE-EXISTS? <string>)
  142. (define (file-exists? f) #f)
  143.  
  144. ;;; (DELETE-FILE <string>)
  145. (define (delete-file f) #f)
  146.  
  147. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  148. ;;; use this definition if your system doesn't have such a procedure.
  149. (define (force-output . arg) #t)
  150.  
  151. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  152. ;;; port versions of CALL-WITH-*PUT-FILE.
  153.  
  154. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  155. ;;; be returned by CHAR->INTEGER.
  156. (define char-code-limit 256)
  157.  
  158. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  159. (define most-positive-fixnum #x0FFFFFFF)
  160.  
  161. ;;; Return argument
  162. (define (identity x) x)
  163.  
  164. ;;; If your implementation provides eval SLIB:EVAL is single argument
  165. ;;; eval using the top-level (user) environment.
  166. ;(define slib:eval eval)
  167.  
  168. ;;; If your implementation provides R4RS macros:
  169. ;(define macro:eval slib:eval)
  170. ;(define macro:load load)
  171.  
  172. (define *defmacros*
  173.   (list (cons 'defmacro
  174.           (lambda (name parms . body)
  175.         `(set! *defmacros* (cons (cons ',name (lambda ,parms ,@body))
  176.                       *defmacros*))))))
  177. (define (defmacro? m) (and (assq m *defmacros*) #t))
  178.  
  179. (define (macroexpand-1 e)
  180.   (if (pair? e) (let ((a (car e)))
  181.           (cond ((symbol? a) (set! a (assq a *defmacros*))
  182.                      (if a (apply (cdr a) (cdr e)) e))
  183.             (else e)))
  184.       e))
  185.  
  186. (define (macroexpand e)
  187.   (if (pair? e) (let ((a (car e)))
  188.           (cond ((symbol? a)
  189.              (set! a (assq a *defmacros*))
  190.              (if a (macroexpand (apply (cdr a) (cdr e))) e))
  191.             (else e)))
  192.       e))
  193.  
  194. (define gentemp
  195.   (let ((*gensym-counter* -1))
  196.     (lambda ()
  197.       (set! *gensym-counter* (+ *gensym-counter* 1))
  198.       (string->symbol
  199.        (string-append "slib:G" (number->string *gensym-counter*))))))
  200.  
  201. (define base:eval slib:eval)
  202. (define (defmacro:eval x) (base:eval (defmacro:expand* x)))
  203. (define (defmacro:expand* x)
  204.   (require 'defmacroexpand) (apply defmacro:expand* x '()))
  205.  
  206. (define (defmacro:load <pathname>)
  207.   (slib:eval-load <pathname> defmacro:eval))
  208.  
  209. (define (slib:eval-load <pathname> evl)
  210.   (if (not (file-exists? <pathname>))
  211.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  212.   (call-with-input-file <pathname>
  213.     (lambda (port)
  214.       (let ((old-load-pathname *load-pathname*))
  215.     (set! *load-pathname* <pathname>)
  216.     (do ((o (read port) (read port)))
  217.         ((eof-object? o))
  218.       (evl o))
  219.     (set! *load-pathname* old-load-pathname)))))
  220.  
  221. ;;; define an error procedure for the library
  222. ;(define slib:error error)
  223.  
  224. ;;; define these as appropriate for your system.
  225. (define slib:tab (integer->char 9))
  226. (define slib:form-feed (integer->char 12))
  227.  
  228. ;;; Define these if your implementation's syntax can support it and if
  229. ;;; they are not already defined.
  230.  
  231. ;(define (1+ n) (+ n 1))
  232. ;(define (-1+ n) (+ n -1))
  233. ;(define 1- -1+)
  234.  
  235. (define in-vicinity string-append)
  236.  
  237. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  238. ;;; return if exitting not supported.
  239. (define slib:exit (lambda args #f))
  240.  
  241. ;;; Here for backward compatability
  242. (define scheme-file-suffix
  243.   (let ((suffix (case (software-type)
  244.           ((NOSVE) "_scm")
  245.           (else ".scm"))))
  246.     (lambda () suffix)))
  247.  
  248. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  249. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  250.  
  251. (define (slib:load-source f) (load (string-append f ".scm")))
  252.  
  253. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  254. ;;; by compiling "foo.scm" if this implementation can compile files.
  255. ;;; See feature 'COMPILED.
  256.  
  257. (define slib:load-compiled load)
  258.  
  259. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  260.  
  261. (define slib:load slib:load-source)
  262.  
  263. (slib:load (in-vicinity (library-vicinity) "require"))
  264.