Jump to page: 1 2
Thread overview
Module for manual memory management
Jan 30, 2015
Foo
Jan 31, 2015
Foo
Jan 31, 2015
Foo
Feb 04, 2015
Foo
Feb 04, 2015
Foo
Feb 04, 2015
Walter Bright
Feb 04, 2015
Foo
Feb 04, 2015
Foo
Feb 07, 2015
Jacob Carlborg
Feb 07, 2015
Foo
Feb 05, 2015
Foo
Feb 05, 2015
Foo
January 30, 2015
Is there interest in such a thing?
I'm currently working on something for my own use and I'm curious if anyone else would be interested in something like that.
I'm aware of Unique, RefCounted, Scoped, emplace and so on, but I'm not a big fan of some implementations (in my opinion not much of it follows the KISS principle). Also, as far as I remember, RefCounted and Unique are somewhat outdated.
As said I'm just curious and I'm aware that my code may be somewhat un-phobos like.

My current stand is this: http://dpaste.dzfl.pl/f1423322b7d5
Just to make it clear: m3 = manual memory management = mmm = m3

and here is some test code: http://dpaste.dzfl.pl/026013fbe19f

I repeat: I know that I reimplement some logic like emplace and that my version is shorter but maybe not quite correct/incomplete.
And I'm also aware of std.allocator and so on, but that is something different IMO.
January 31, 2015
On 1/30/15 3:49 PM, Foo wrote:
> Is there interest in such a thing?
> I'm currently working on something for my own use and I'm curious if
> anyone else would be interested in something like that.
> I'm aware of Unique, RefCounted, Scoped, emplace and so on, but I'm not
> a big fan of some implementations (in my opinion not much of it follows
> the KISS principle). Also, as far as I remember, RefCounted and Unique
> are somewhat outdated.
> As said I'm just curious and I'm aware that my code may be somewhat
> un-phobos like.
>
> My current stand is this: http://dpaste.dzfl.pl/f1423322b7d5
> Just to make it clear: m3 = manual memory management = mmm = m3
>
> and here is some test code: http://dpaste.dzfl.pl/026013fbe19f
>
> I repeat: I know that I reimplement some logic like emplace and that my
> version is shorter but maybe not quite correct/incomplete.

So why come with your own self-admitted incomplete/incorrect alternatives instead of adding/improving the standard ones? If something's there that shouldn't, remove it. I don't get this "I didn't get it so I'll redo it incompletely".

> And I'm also aware of std.allocator and so on, but that is something
> different IMO.

Agreed.


Andrei

January 31, 2015
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote:
> On 1/30/15 3:49 PM, Foo wrote:
>> Is there interest in such a thing?
>> I'm currently working on something for my own use and I'm curious if
>> anyone else would be interested in something like that.
>> I'm aware of Unique, RefCounted, Scoped, emplace and so on, but I'm not
>> a big fan of some implementations (in my opinion not much of it follows
>> the KISS principle). Also, as far as I remember, RefCounted and Unique
>> are somewhat outdated.
>> As said I'm just curious and I'm aware that my code may be somewhat
>> un-phobos like.
>>
>> My current stand is this: http://dpaste.dzfl.pl/f1423322b7d5
>> Just to make it clear: m3 = manual memory management = mmm = m3
>>
>> and here is some test code: http://dpaste.dzfl.pl/026013fbe19f
>>
>> I repeat: I know that I reimplement some logic like emplace and that my
>> version is shorter but maybe not quite correct/incomplete.
>
> So why come with your own self-admitted incomplete/incorrect alternatives instead of adding/improving the standard ones? If something's there that shouldn't, remove it. I don't get this "I didn't get it so I'll redo it incompletely".
Too much and too long code. ;)
Sometimes it is better to see a new version from scratch to rethink old ones. ;) I'm not for removing them, I'm for rebuilding them. And a new version can bring new wind into the sails. That's why I'm presented my code here: for discussion.
But that is not that important, my main target was the implementation of Unique and Shared. You can adapt them with minimal effort. But I'm quite sure that my 'make' function is not yet present in phobos.
So, what do you think about discussing if and how my make, Unique and Shared could improve phobos.

>> And I'm also aware of std.allocator and so on, but that is something
>> different IMO.
>
> Agreed.
>
>
> Andrei

January 31, 2015
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote:
> On 1/30/15 3:49 PM, Foo wrote:
>> Is there interest in such a thing?
>> I'm currently working on something for my own use and I'm curious if
>> anyone else would be interested in something like that.
>> I'm aware of Unique, RefCounted, Scoped, emplace and so on, but I'm not
>> a big fan of some implementations (in my opinion not much of it follows
>> the KISS principle). Also, as far as I remember, RefCounted and Unique
>> are somewhat outdated.
>> As said I'm just curious and I'm aware that my code may be somewhat
>> un-phobos like.
>>
>> My current stand is this: http://dpaste.dzfl.pl/f1423322b7d5
>> Just to make it clear: m3 = manual memory management = mmm = m3
>>
>> and here is some test code: http://dpaste.dzfl.pl/026013fbe19f
>>
>> I repeat: I know that I reimplement some logic like emplace and that my
>> version is shorter but maybe not quite correct/incomplete.
>
> So why come with your own self-admitted incomplete/incorrect alternatives instead of adding/improving the standard ones? If something's there that shouldn't, remove it. I don't get this "I didn't get it so I'll redo it incompletely".
>
>> And I'm also aware of std.allocator and so on, but that is something
>> different IMO.
>
> Agreed.
>
>
> Andrei

And I did not literally said 'incorrect'. I said _maybe_ incomplete. In my tests it works properly. What I meant with 'not quite correct' was that it isn't well tested _yet_. But that can be done later.
February 04, 2015
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
February 04, 2015
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

February 04, 2015
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!
February 04, 2015
On 2/4/2015 12:42 PM, Foo wrote:
> On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:
>> @trusted
>> @nogc
>> char[] read(const string filename) nothrow {
> 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! :)

No need to reinvent this:

  https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
  line 194

Just use it and change the allocator bit.

February 04, 2015
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright wrote:
> On 2/4/2015 12:42 PM, Foo wrote:
>> On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:
>>> @trusted
>>> @nogc
>>> char[] read(const string filename) nothrow {
>> 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! :)
>
> No need to reinvent this:
>
>   https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
>   line 194
>
> Just use it and change the allocator bit.

Yes, I've also looked at that. But I think my code is more readable and easier to understand. But I will take a second look. ;)

BTW: You can redirect to the line by adding #194: https://github.com/D-Programming-Language/phobos/blob/master/std/file.d#L194 just click on the line number on the left.
February 04, 2015
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright
wrote:
> On 2/4/2015 12:42 PM, Foo wrote:
>> On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:
>>> @trusted
>>> @nogc
>>> char[] read(const string filename) nothrow {
>> 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! :)
>
> No need to reinvent this:
>
>   https://github.com/D-Programming-Language/phobos/blob/master/std/file.d
>   line 194
>
> Just use it and change the allocator bit.

It would be much easier for me, if some of you would add such a
allocator to it. :P
« First   ‹ Prev
1 2