projects
/
jscl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Newlines after semicolons if *PRETTY-PRINT* is set.
[jscl.git]
/
src
/
stream.lisp
diff --git
a/src/stream.lisp
b/src/stream.lisp
index
bd72cf9
..
086b145
100644
(file)
--- a/
src/stream.lisp
+++ b/
src/stream.lisp
@@
-19,27
+19,39
@@
;;; TODO: Use structures to represent streams, but we would need
;;; inheritance.
;;; TODO: Use structures to represent streams, but we would need
;;; inheritance.
-(defvar *standard-output*)
+(/debug "loading stream.lisp!")
+
+(defvar *standard-output*
+ (vector 'stream
+ (lambda (ch) (%write-string (string ch)))
+ (lambda (string) (%write-string string))))
(defun streamp (x)
(and (vectorp x) (eq (aref x 0) 'stream)))
(defun streamp (x)
(and (vectorp x) (eq (aref x 0) 'stream)))
+(defun write-char (char &optional (stream *standard-output*))
+ (funcall (aref stream 1) char))
+
+(defun write-string (string &optional (stream *standard-output*))
+ (funcall (aref stream 2) string))
+
+
(defun make-string-output-stream ()
(let ((buffer (make-string 0)))
(vector 'stream
;; write-char
(lambda (ch)
(vector-push-extend ch buffer))
(defun make-string-output-stream ()
(let ((buffer (make-string 0)))
(vector 'stream
;; write-char
(lambda (ch)
(vector-push-extend ch buffer))
+ (lambda (string)
+ (dotimes (i (length string))
+ (vector-push-extend (aref string i) buffer)))
'string-stream
buffer)))
(defun get-output-stream-string (stream)
'string-stream
buffer)))
(defun get-output-stream-string (stream)
- (eq (aref stream 2) 'string-stream)
- (prog1 (aref stream 3)
- (aset stream 3 (make-string 0))))
-
-(defun write-char (char &optional (stream *standard-output*))
- (funcall (aref stream 1) char))
+ (eq (aref stream 3) 'string-stream)
+ (prog1 (aref stream 4)
+ (aset stream 4 (make-string 0))))
(defmacro with-output-to-string ((var) &body body)
`(let ((,var (make-string-output-stream)))
(defmacro with-output-to-string ((var) &body body)
`(let ((,var (make-string-output-stream)))