pseudoscheme-features.scm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*-
  2. ; Copyright (c) 1993-2007 by Richard Kelsey and Jonathan Rees. See file COPYING.
  3. ; This is file pseudoscheme-features.scm.
  4. ; Synchronize any changes with all the other *-features.scm files.
  5. (define *scheme-file-type* #f) ;For fun
  6. ; SIGNALS
  7. (define error #'ps:scheme-error)
  8. (define warn #'ps:scheme-warn)
  9. (define (signal type . stuff)
  10. (apply warn "condition signalled" type stuff))
  11. (define (syntax-error . rest) ; Must return a valid expression.
  12. (apply warn rest)
  13. ''syntax-error)
  14. (define (call-error message proc . args)
  15. (error message (cons proc args)))
  16. ; FEATURES
  17. (define force-output #'lisp:force-output)
  18. (define (string-hash s)
  19. (let ((n (string-length s)))
  20. (do ((i 0 (+ i 1))
  21. (h 0 (+ h (lisp:char-code (string-ref s i)))))
  22. ((>= i n) h))))
  23. (define (make-immutable! thing) thing)
  24. (define (immutable? thing) #f)
  25. ; BITWISE
  26. (define arithmetic-shift #'lisp:ash)
  27. (define bitwise-and #'lisp:logand)
  28. (define bitwise-ior #'lisp:logior)
  29. (define bitwise-not #'lisp:lognot)
  30. ; ASCII
  31. (define char->ascii #'lisp:char-code)
  32. (define ascii->char #'lisp:code-char)
  33. (define ascii-limit lisp:char-code-limit)
  34. (define ascii-whitespaces '(32 10 9 12 13))
  35. ; CODE-VECTORS
  36. (define (make-code-vector len . fill-option)
  37. (lisp:make-array len :element-type '(lisp:unsigned-byte 8)
  38. :initial-element (if (null? fill-option)
  39. 0
  40. (car fill-option))))
  41. (define (code-vector? obj)
  42. (ps:true? (lisp:typep obj
  43. (lisp:quote (lisp:simple-array (lisp:unsigned-byte 8)
  44. (lisp:*))))))
  45. (define (code-vector-ref bv k)
  46. (lisp:aref (lisp:the (lisp:simple-array (lisp:unsigned-byte 8) (lisp:*))
  47. bv)
  48. k))
  49. (define (code-vector-set! bv k val)
  50. (lisp:setf (lisp:aref (lisp:the (lisp:simple-array (lisp:unsigned-byte 8)
  51. (lisp:*))
  52. bv)
  53. k)
  54. val))
  55. (define (code-vector-length bv)
  56. (lisp:length (lisp:the (lisp:simple-array (lisp:unsigned-byte 8) (lisp:*))
  57. bv)))
  58. (define (write-byte byte port)
  59. (write-char (ascii->char byte) port))
  60. ; The rest is unnecessary in Pseudoscheme versions 2.8d and after.
  61. ;(define eval #'schi:scheme-eval)
  62. ;(define (interaction-environment) schi:*current-rep-environment*)
  63. ;(define scheme-report-environment
  64. ; (let ((env (scheme-translator:make-program-env
  65. ; 'rscheme
  66. ; (list scheme-translator:revised^4-scheme-module))))
  67. ; (lambda (n)
  68. ; n ;ignore
  69. ; env)))
  70. ; Dynamic-wind.
  71. ;
  72. ;(define (dynamic-wind in body out)
  73. ; (in)
  74. ; (lisp:unwind-protect (body)
  75. ; (out)))
  76. ;
  77. ;(define values #'lisp:values)
  78. ;
  79. ;(define (call-with-values thunk receiver)
  80. ; (lisp:multiple-value-call receiver (thunk)))