Discussion:
[Larceny-users] Request: string-port? predicate
KenD
2016-06-25 23:47:24 UTC
Permalink
I would like to implement a function which returns the "contents" of a port as a string.

It would be useful to test an output-port to see if get-output-string can be applied.

[larceny in -r7rs bahaves:]
(import (primitives string-output-port?))
string-output-port?
Error: unhandled condition:
...
message : "?: undefined global variable: string-output-port? \n"
(import (primitives string-port?))
string-port?
Error: unhandled condition:
...
message : "?: undefined global variable: string-port? \n"

It would also be useful to know the byte-length of a file, and deal with directory and file entries..

Thanks much,
-KenD
William D Clinger
2016-06-28 17:17:28 UTC
Permalink
Post by KenD
It would be useful to test an output-port to see if get-output-string can be applied.
Yes. A temporary workaround can be found at:

https://github.com/larcenists/larceny/issues/772
Post by KenD
It would also be useful to know the byte-length of a file, and deal with directory and file entries..
In R5RS mode:

(require 'file-system)
(require 'file-utils)

The first of those gives you file-length, file-directory?, and
a few other things. The second gives you some higher-level stuff
like diff. The source code is in lib/Standard/file-system.sch
and file-utils.sch.

In R7RS mode, use r5rs:require instead of plain require before
importing the stuff you need:

(import (primitives r5rs:require))
(r5rs:require 'file-system)
(import (primitives file-length))

Will

Loading...