At 2002-08-10 03:03, anatoli wrote:
--- Sven Moritz Hallberg <pesco@gmx.de> wrote:
I argue _strongly_ against associating some sort of locale state with handles.
1) In agreement with Ashley's statements, file IO should use octets, because that's what's in a file.
By the same token, we should handle CR/LF/CR-LF/LF-CR mess by hand. (Files don't have lines in them, they are just sequences of octets.)
Correct. Exactly what kind of newline do you want in your file?
I prefer somewhat higher-level view of files.
Well, that's what encoding functions are for. You can take higher-level views of your octets as text, images, XML-structures, experimental datasets, whatever. What's so special about text that the functionality should be bound _right into the API_?
2) If you need to decode those octets to characters, or vice-versa, compose a (de)serialization function before it.
I *always* need that. (Except for binary IO).
You *always* need that. (Except when you don't). The term of "binary" is quite misleading. It suggests a particular file type, but it's actually used to mean "something other than ASCII-compatible text". One might as well have a word that means "something other than a JPEG image". ...
A "Word8 stream" can be either Handle (Word8Handle?) or [Word8]. We can transform [Word8] to [Char], but not Word8Handle to CharHandle. I argue that the latter is needed as well.
Well, it should be a utility library built on top of the real Word8-based functions: data TextHandle = MkTextHandle Handle TextEncoding; etc. -- Ashley Yakeley, Seattle WA
--- Ashley Yakeley <ashley@semantic.org> wrote:
By the same token, we should handle CR/LF/CR-LF/LF-CR mess by hand. (Files don't have lines in them, they are just sequences of octets.)
Correct. Exactly what kind of newline do you want in your file?
The correct answer depends on the level of abstraction. It can be either "some specific kind of newline" or "whatever kind the OS wants", but mostly it's "I don't care" (i.e. "whatever kind the Handle wants").
A "Word8 stream" can be either Handle (Word8Handle?) or [Word8]. We can transform [Word8] to [Char], but not Word8Handle to CharHandle. I argue that the latter is needed as well.
Well, it should be a utility library built on top of the real Word8-based functions:
data TextHandle = MkTextHandle Handle TextEncoding; etc.
I have no problem with that, except for the naming. Current IO functions are mostly text-based and centered around Handles, and there's no good reason to break that. Thus, your TextHandle probably should be a Handle and your Handle probably should be a BinaryHandle. Plus, the utility library should probably live on the C side, but that's an implementation detail :) -- a. __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com
participants (2)
-
anatoli -
Ashley Yakeley