www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - phobos redundancy

reply Carlos Santander B. <Carlos_member pathlink.com> writes:
I'm not sure if I should say it's a bug, but that's what it seems to me.
IMHO, there's a huge redundancy in phobos between std.stream.MemoryStream and
std.mmfile.Mmfile. Shouldn't one of them be gone? I vote for MemoryStream to
stay because it can be used with the rest of std.stream, as opposed to Mmfile
which is a stand-alone class.

-------------------
Carlos Santander B.
Jun 04 2004
next sibling parent reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
There is a difference between the two; for high performance with *very*
large files I think memory-mapped IO is the right way to go (whereas
MemoryStream would presumably wind up using standard buffered IO).

However, mmfile does not fit cleanly into the IO structure, as you point
out, which makes it a bit of a sore thumb. Ideally, all this stuff would
blend perfectly together to provide a seamless and symmetrical
high-performance IO library.

Wait a minute! ... that's *exactly* what mango.io does!

<g>

<shameful plug/>

"Carlos Santander B." <Carlos_member pathlink.com> wrote in message
news:c9qc2q$187r$1 digitaldaemon.com...
 I'm not sure if I should say it's a bug, but that's what it seems to me.
 IMHO, there's a huge redundancy in phobos between std.stream.MemoryStream
and
 std.mmfile.Mmfile. Shouldn't one of them be gone? I vote for MemoryStream
to
 stay because it can be used with the rest of std.stream, as opposed to
Mmfile
 which is a stand-alone class.

 -------------------
 Carlos Santander B.
Jun 04 2004
parent "Carlos Santander B." <carlos8294 msn.com> writes:
"Kris" <someidiot earthlink.dot.dot.dot.net> escribió en el mensaje
news:c9qdcc$1a7d$1 digitaldaemon.com
| There is a difference between the two; for high performance with *very*
| large files I think memory-mapped IO is the right way to go (whereas
| MemoryStream would presumably wind up using standard buffered IO).
|

Wouldn't know about that.

| However, mmfile does not fit cleanly into the IO structure, as you point
| out, which makes it a bit of a sore thumb. Ideally, all this stuff would
| blend perfectly together to provide a seamless and symmetrical
| high-performance IO library.
|

Exactly.

| Wait a minute! ... that's *exactly* what mango.io does!
|
| <g>
|
| <shameful plug/>
|

I guess the plug is fine, but it's still not phobos.

-----------------------
Carlos Santander Bernal
Jun 04 2004
prev sibling parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
Hmmm. It shouldn't be too bad to parameterize MemoryStream (or call it
something else like ArrayStream so that it doesn't conflict with the
existing MemoryStream) by the buffer type as long as the buffer supports
.length, opIndex and opSlice. Then MemoryStream would just be
ArrayStream!(ubyte[]) and a Stream wrapper around MmFile would be
ArrayStream!(MmFile). I'll see if that works out and post if I get anywhere.


"Carlos Santander B." <Carlos_member pathlink.com> wrote in message
news:c9qc2q$187r$1 digitaldaemon.com...
 I'm not sure if I should say it's a bug, but that's what it seems to me.
 IMHO, there's a huge redundancy in phobos between std.stream.MemoryStream
and
 std.mmfile.Mmfile. Shouldn't one of them be gone? I vote for MemoryStream
to
 stay because it can be used with the rest of std.stream, as opposed to
Mmfile
 which is a stand-alone class.

 -------------------
 Carlos Santander B.
Jun 04 2004
parent reply Ben Hinkle <bhinkle4 juno.com> writes:
Based on std.stream.MemoryStream I added a very short TArrayStream
parameterized class to std.stread and put the file at
http://home.comcast.net/~benhinkle/stream.d
I'd paste the code here but I think the license rules are clearer if I keep
the file in one piece. Here's how it would be used in practice with MmFile:

import std.stream;
import std.mmfile;

int main() {
  auto MmFile file = new MmFile("foo"); // foo is a text file
  TArrayStream!(MmFile) mms = new TArrayStream!(MmFile)(file);
  while (!mms.eof()) {
    printf("-%.*s-\n",mms.readLine());
  }
  return 0;
}
Jun 04 2004
parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Ben; you fiend ...

Why can't you just let that darned standard IO library rot in peace

:-)


"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:c9r153$26t2$1 digitaldaemon.com...
 Based on std.stream.MemoryStream I added a very short TArrayStream
 parameterized class to std.stread and put the file at
 http://home.comcast.net/~benhinkle/stream.d
 I'd paste the code here but I think the license rules are clearer if I
keep
 the file in one piece. Here's how it would be used in practice with
MmFile:
 import std.stream;
 import std.mmfile;

 int main() {
   auto MmFile file = new MmFile("foo"); // foo is a text file
   TArrayStream!(MmFile) mms = new TArrayStream!(MmFile)(file);
   while (!mms.eof()) {
     printf("-%.*s-\n",mms.readLine());
   }
   return 0;
 }
Jun 04 2004