digitalmars.D - Module for manual memory management
- Foo (16/16) Jan 30 2015 Is there interest in such a thing?
- Andrei Alexandrescu (7/23) Jan 30 2015 So why come with your own self-admitted incomplete/incorrect
- Foo (13/46) Jan 31 2015 Too much and too long code. ;)
- Foo (6/39) Jan 31 2015 And I did not literally said 'incorrect'. I said _maybe_
- Foo (10/10) Feb 04 2015 For what it's worth, today I finished the current work. Now we
- Andrei Alexandrescu (22/31) Feb 04 2015 Opened File.d at random:
- Foo (13/53) Feb 04 2015 Yes that is correct, currently there is no error checking, maybe
- Walter Bright (5/12) Feb 04 2015 No need to reinvent this:
- Foo (8/25) Feb 04 2015 Yes, I've also looked at that. But I think my code is more
- Foo (4/21) Feb 04 2015 It would be much easier for me, if some of you would add such a
- Jacob Carlborg (6/9) Feb 07 2015 Just for the record, you can get a link to the exact line by clicking on...
- Foo (3/12) Feb 07 2015 The same I've said a page previously. Funny. :)
- Foo (6/46) Feb 04 2015 I would be glad if you or Walter could review the other parts as
- Andrei Alexandrescu (3/6) Feb 04 2015 Your code is a ways from being in reviewable form. It would be great if
- Foo (4/14) Feb 05 2015 Oh, I didn't thought that it is so bad. :D It works splendidly so
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.
Jan 30 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
Jan 30 2015
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote:On 1/30/15 3:49 PM, Foo wrote: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.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
Jan 31 2015
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote:On 1/30/15 3:49 PM, Foo wrote: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.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
Jan 31 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
Feb 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/m3Opened 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
Feb 04 2015
On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:On 2/4/15 9:13 AM, Foo wrote: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!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/m3Opened 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
Feb 04 2015
On 2/4/2015 12:42 PM, Foo wrote:On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: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.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! :)
Feb 04 2015
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright wrote:On 2/4/2015 12:42 PM, Foo wrote: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. ;) https://github.com/D-Programming-Language/phobos/blob/master/std/file.d#L194 just click on the line number on the left.On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: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.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! :)
Feb 04 2015
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright wrote:On 2/4/2015 12:42 PM, Foo wrote:It would be much easier for me, if some of you would add such a allocator to it. :POn Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: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.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! :)
Feb 04 2015
On 2015-02-04 21:55, Walter Bright wrote:No need to reinvent this: https://github.com/D-Programming-Language/phobos/blob/master/std/file.d line 194Just for the record, you can get a link to the exact line by clicking on the line number in the left margin and the copying the link from the address bar. -- /Jacob Carlborg
Feb 07 2015
On Saturday, 7 February 2015 at 11:29:51 UTC, Jacob Carlborg wrote:On 2015-02-04 21:55, Walter Bright wrote:The same I've said a page previously. Funny. :)No need to reinvent this: https://github.com/D-Programming-Language/phobos/blob/master/std/file.d line 194Just for the record, you can get a link to the exact line by clicking on the line number in the left margin and the copying the link from the address bar.
Feb 07 2015
On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote:On 2/4/15 9:13 AM, Foo wrote:I would be glad if you or Walter could review the other parts as well. I'm very sure that your review will be very helpful and I'm convinced that the modules Array or Smart Pointer could be useful for phobos.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/m3Opened 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
Feb 04 2015
On 2/4/15 11:48 PM, Foo wrote:I would be glad if you or Walter could review the other parts as well. I'm very sure that your review will be very helpful and I'm convinced that the modules Array or Smart Pointer could be useful for phobos.Your code is a ways from being in reviewable form. It would be great if a member of the community could act as a mentor. -- Andrei
Feb 04 2015
On Thursday, 5 February 2015 at 07:53:34 UTC, Andrei Alexandrescu wrote:On 2/4/15 11:48 PM, Foo wrote:Oh, I didn't thought that it is so bad. :D It works splendidly so far for us. Sorry, that I'm wasting your time. :)I would be glad if you or Walter could review the other parts as well. I'm very sure that your review will be very helpful and I'm convinced that the modules Array or Smart Pointer could be useful for phobos.Your code is a ways from being in reviewable form. It would be great if a member of the community could act as a mentor. -- Andrei
Feb 05 2015