Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Providing IO utilities

Sebastian Bensusan edited this pageSep 30, 2015 ·2 revisions

clojure.java.io offers a standard way of doing I/O for Clojure JVM programs. As the ClojureScript ecosystem grows, there is demand for similar capabilities. I/O is inherently platform dependent and it is likely impossible to offer a drop-in-replacement ofclojure.java.io for any JavaScript environment. Then, it is necessary to define the desired behavior of an IO library for ClojureScript in each target platform. There are at least two distinct paths:

Replicate Java's behavior

Java's I/O is built around I/O Streams, a concept based on a set of interfaces: Closable.close, DataInput.read, DataOutput.write. Those interfaces can be implemented over many Java classes: e.g.,InputStream,File,URI,URL,Socket, andString.

Node.js has both aStream API and aFile System module. The File System API supports creating streams from Files.

Browsers don't offer Stream APIs and have other I/O needs: files are not common and most I/O is associated to XHR and Websockets. Websockets API follow message-passing conventions and I'm not sure if Streams are a good fit.

Wrap existing APIs

We can embrace each platform's concept of I/O and provide without attempting to recreateclojure.java.io functionality. For example, Node provides aFile System module. The problem with FS is that is based on strings as file representations with no concept of reified files.

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp