Guile port example fix for Guile 2.0
Rewinding the file before passing it to C fixed the problem of not being able to read the file contents. Also explain the error about writing to a string.
This commit is contained in:
parent
0f1e3da5de
commit
8700e79b3e
1 changed files with 3 additions and 2 deletions
|
|
@ -21,14 +21,15 @@
|
|||
(lambda ()
|
||||
(print-int (current-output-port) 314159))))
|
||||
(lambda args
|
||||
(display "Attempting to write to a string or soft port will result in this error:")
|
||||
(display "Below shows that attempting to write to a string or soft port will result in a wrong-type-error...")
|
||||
(newline)
|
||||
(write args) (newline)))
|
||||
|
||||
;; Read from a file port. Note that it is a bad idea to mix Scheme and
|
||||
;; C input because of buffering.
|
||||
;; C input because of buffering, hence the call to seek to rewind the file.
|
||||
(with-input-from-file "test.out"
|
||||
(lambda ()
|
||||
(seek (current-input-port) 0 SEEK_SET)
|
||||
(display (read-int (current-input-port)))
|
||||
(newline)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue