Revision 35a186be87ca6f1dcb07fa606792395c3492b8bf authored by Ian Butterworth on 08 April 2021, 01:07:31 UTC, committed by GitHub on 08 April 2021, 01:07:31 UTC
* fold repeated `LoadError :` prints during showerror

* Only print a single LoadError: prefix
1 parent 263451e
Raw File
aliases.scm
; definitions of standard scheme procedures in terms of femtolisp procedures

(define-macro (begin0 first . rest)
  `(prog1 ,first ,@rest))

(define vector-ref aref)
(define vector-set! aset!)
(define vector-length length)

(define char=? eqv?)
(define char<? <)
(define char>? >)
(define char<=? <=)
(define char>=? >=)
(define (char-numeric? c) (not (not (string.find "0123456789" c))))

(define string-append string)
(define string-length string.count)
(define string->symbol symbol)
(define (symbol->string s) (string s))

(define (list->string l) (apply string l))
(define (string->list s)
  (let loop ((i (sizeof s))
	     (l '()))
    (if (= i 0)
	l
	(let ((newi (string.dec s i)))
	  (loop newi (cons (string.char s newi) l))))))

(define (substring s start end)
  (string.sub s (string.inc s 0 start) (string.inc s 0 end)))

(define (port? x) (iostream? x))
(define (read-char (s *input-stream*)) (io.getc s))
(define (peek-char (s *input-stream*)) (io.peekc s))
(define (write-char c (s *output-stream*)) (io.putc s c))

(define (port-eof? p) (io.eof? p))
(define (open-input-string str)
  (let ((b (buffer)))
    (io.write b str)
    (io.seek b 0)
    b))
(define (open-output-string) (buffer))
(define (open-string-output-port)
  (let ((b (buffer)))
    (values b (lambda () (io.tostring! b)))))

(define (get-output-string b)
  (let ((p (io.pos b)))
    (io.seek b 0)
    (let ((s (io.readall b)))
      (io.seek b p)
      (if (eof-object? s) "" s))))

(define (open-input-file name) (file name :read))
(define (open-output-file name) (file name :write :create))

(define (current-input-port (p *input-stream*))
  (set! *input-stream* p))
(define (current-output-port (p *output-stream*))
  (set! *output-stream* p))

(define (display x (port *output-stream*))
  (with-output-to port (princ x))
  #t)

; --- gambit

(define (with-exception-catcher hand thk)
  (trycatch (thk)
	    (lambda (e) (hand e))))

(define make-table table)
(define table-ref get)
(define table-set! put!)
back to top