On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:
On 2/4/15 9:13 AM, Foo wrote:
For what it's worth, today I finished the current work. Now we will start working with it. If someone has critique, improvement suggestions
or want to take some ideas, he is free to do so.
To repeat myself: we rewrote some functionality which already existed in D, but were improvable. For example the existing emplace method is quite long, hard to understand / read and is not marked with @nogc. Since we want to avoid the GC wherever possible we had to rewrite it. I hope it's useful for someone else and that some of you guys take some ideas from it.

https://github.com/Dgame/m3

Opened File.d at random:

@trusted
@nogc
char[] read(const string filename) nothrow {
import std.c.stdio : FILE, SEEK_END, SEEK_SET, fopen, fclose, fseek, ftell, fread;

    FILE* f = fopen(filename.ptr, READ_BINARY);
    scope(exit) fclose(f);

    fseek(f, 0, SEEK_END);
    immutable size_t fsize = ftell(f);
    fseek(f, 0, SEEK_SET);

    char[] str = m3.m3.make!(char[])(fsize);
    fread(str.ptr, fsize, 1, f);

    return str;
}

Then stopped right there. This is nowhere near production quality - there is no error checking whatsoever, does more operations than necessary, won't work on special files etc. etc. etc.

I applaud the intention but there is a lot more work to be done on this before it's in reviewable form.


Andrei

Yes that is correct, currently there is no error checking, maybe it get that later. But what do you mean with "it use more operations than necessary"? I can't see it. But both points are helpful critique. Thanks a lot! :)

As I said above, it's currently only for our work. But I presented it here, so that some guys can get some inspiration or can reuse our code. :) Maybe, but really only maybe, I will get some work done, so that it's is ready for phobos. But since such a review can take years, I see no use to do that work. But if someone else has the will to do that, reuse our code!

Reply via email to