Re: Namespace for a module defined by its import path
On Tuesday, 8 November 2016 at 18:33:13 UTC, Jeff Thompson wrote: On Tuesday, 8 November 2016 at 17:00:44 UTC, Jeff Thompson wrote: On Wednesday, 26 October 2016 at 17:12:30 UTC, Jonathan Marler wrote: On Wednesday, 26 October 2016 at 09:53:35 UTC, Jeff Thompson wrote: [...] I've thought about this and have concluded that you can't replicate these semantics in D. Here's 2 solutions though: [...] Right now, if a module doesn't have a package statement, the module name is the file name with the path and and extension stripped off. My problem would be solved by a compiler option to keep the path. ... or is there a way to get the path at compile time? I could try some mixin magic to construct the package name including the path. I guess this is what you're looking for: http://dlang.org/changelog/2.072.0.html#__FILE_FULL_PATH__
Re: Array operation with overlapping
On Tuesday, 8 November 2016 at 14:52:41 UTC, Steven Schveighoffer wrote: On 11/8/16 3:29 AM, Oleg Gorbunov wrote: I am new in D, but saw some strage behavour. Overlapping is detected for + and * array operation, but not for - and /. I would say this is a bug. The behavior should be consistent. -Steve OK, I'll report this bug at https://issues.dlang.org
Re: Question on syntax
On Wednesday, 9 November 2016 at 06:28:31 UTC, Jim wrote: What does it mean when a variable name starts with a '.' `.a` --> `::a`.
[Issue 16675] New: Overlapping is detected at runtime for + and * array operation, but not for - and /.
https://issues.dlang.org/show_bug.cgi?id=16675 Issue ID: 16675 Summary: Overlapping is detected at runtime for + and * array operation, but not for - and /. Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: olegu...@gmail.com I am new in D, but saw some strage behaviour. Overlapping is detected for + and * array operation, but not for - and /. Ex. import std.stdio; void main() { int[] slice = [2, 2, 2, 2]; int[] slice2 = slice[0 .. $ - 1]; int[] slice3 = slice[1 .. $]; writeln("slice before: ", slice); writeln("slice2 before: ", slice2); writeln("slice3 before: ", slice3); enum cmd = "slice3[] = slice2[] + slice3[];"; writeln( "cmd: ", cmd ); mixin( cmd ); writeln("slice after : ", slice); writeln("slice2 after : ", slice2); writeln("slice3 after : ", slice3); } When this code is run at 'dlang.org' online compiler slice before: [2, 2, 2, 2] slice2 before: [2, 2, 2] slice3 before: [2, 2, 2] cmd: slice3[] = slice2[] + slice3[]; object.Error@(0): Overlapping arrays in vector operation: 8 byte(s) overlap of 12 ??:? nothrow @safe void rt.util.array._enforceNoOverlap(const(char[]), ulong, ulong, const(ulong)) [0x44f7f3] ??:? _arraySliceSliceAddSliceAssign_i [0x44c1b6] ??:? _Dmain [0x4408bb] ??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x44c8a6] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c7f0] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x44c862] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c7f0] ??:? _d_run_main [0x44c761] ??:? main [0x44a389] ??:? __libc_start_main [0x40d80a14] OK If change + to - enum cmd = "slice3[] = slice2[] - slice3[];"; When it is run at 'dlang.org' slice before: [2, 2, 2, 2] slice2 before: [2, 2, 2] slice3 before: [2, 2, 2] cmd: slice3[] = slice2[] - slice3[]; slice after : [2, 0, -2, -4] slice2 after : [2, 0, -2] slice3 after : [0, -2, -4] The same behaviour I saw in Windows with DMD2.072.0 and DMD2.069.2 --
Re: Question on syntax
On 09/11/2016 7:28 PM, Jim wrote: Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What does it mean when a variable name starts with a '.' Here's an extract from the code: /// move.d module move; import empire; import eplayer; import sub2; [...] void updlst(loc_t loc,int type)// update map value at loc { int ty = .typ[.map[loc]];// what's there ... etc. (loc_t is an alias for int) Would the equivalent in C or C++ be: typedef int loc_t; extern int typ[]; extern int map[]; void updlst( loc_t loc, int type ) { int ty = typ[map[loc]]; /// var.d module var; import empire; import eplayer; int typ[MAPMAX] = ...etc... ubyte map[MAPSIZE] = [0,];// reference map If you need more context, the complete source code is available from http://www.classicempire.com/ This is a set of syntax that isn't ugh used often (I'm pretty sure I know what it is). It just isn't needed. Empire's code was ported to D during the early days of D1, its documentation doesn't come close to best practices let alone the code itself. Example: int x; void main() { x = 8; import std.stdio; writeln(.x); }
Question on syntax
Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What does it mean when a variable name starts with a '.' Here's an extract from the code: /// move.d module move; import empire; import eplayer; import sub2; [...] void updlst(loc_t loc,int type) // update map value at loc { int ty = .typ[.map[loc]];// what's there ... etc. (loc_t is an alias for int) Would the equivalent in C or C++ be: typedef int loc_t; extern int typ[]; extern int map[]; void updlst( loc_t loc, int type ) { int ty = typ[map[loc]]; /// var.d module var; import empire; import eplayer; int typ[MAPMAX] = ...etc... ubyte map[MAPSIZE] = [0,]; // reference map If you need more context, the complete source code is available from http://www.classicempire.com/
Re: Is the following code legal?
On 09/11/16 07:02, Stefan Koch wrote: On Wednesday, 9 November 2016 at 05:00:28 UTC, Shachar Shemesh wrote: On 08/11/16 17:41, Kagamin wrote: no Is this officially declared in the policy? Should I open an issue? Shachar Please open an issue. Ask and thy shall receive. https://issues.dlang.org/show_bug.cgi?id=16674
[Issue 16674] New: Clarify lifetime of pointer to AA entry
https://issues.dlang.org/show_bug.cgi?id=16674 Issue ID: 16674 Summary: Clarify lifetime of pointer to AA entry Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dlang.org Assignee: nob...@puremagic.com Reporter: shac...@shemesh.biz SomeType[SomeOtherType] aa; ... SomeType* aap = aKey in aa; The lifetime of aap needs to be clarified. In particular with respect to: * Removal of aKey from the aa * Removal of another element from the aa * Addition of another element to the aa * Modification of an existing element in the aa with "aa[key] = something" * Modification of this element in the aa with "aa[aKey] = something". --
Re: Is the following code legal?
On Wednesday, 9 November 2016 at 05:00:28 UTC, Shachar Shemesh wrote: On 08/11/16 17:41, Kagamin wrote: no Is this officially declared in the policy? Should I open an issue? Shachar Please open an issue.
Re: Is the following code legal?
On 08/11/16 17:41, Kagamin wrote: no Is this officially declared in the policy? Should I open an issue? Shachar
[Issue 16488] [spec][optimization] broadcast scalar to simd vector
https://issues.dlang.org/show_bug.cgi?id=16488 --- Comment #2 from Walter Bright--- https://github.com/dlang/dmd/pull/6248 --
Re: [OT] Re: CTFE Status
On Tue, 08 Nov 2016 11:44:50 -0500, Nick Sabalausky wrote: > I really wish Google would take that to heart. They seem to make a habit > of ripping things out *before* having replacements in place. > > I think they just simply love deleting code. I've seen this more internally than externally. The joke was that there are two versions of everything: the deprecated one, and the one that doesn't work yet.
Re: CTFE Status
On Tuesday, 8 November 2016 at 21:56:32 UTC, Stefan Koch wrote: Back to CTFE. The 64Bit bug is fixed. And now there is one bailout-line less. I am onto the next bug. Let's hunt them all down! https://media.giphy.com/media/FmNXeuoadNTpe/giphy.gif
Re: Question about dsfml.system.err
On Tuesday, 8 November 2016 at 19:00:15 UTC, Steven Schveighoffer wrote: On 11/8/16 11:48 AM, Konstantin Kutsevalov wrote: On Tuesday, 8 November 2016 at 16:34:04 UTC, Konstantin Kutsevalov wrote: ADD: I tried to open other stream in main() ``` ... import dsfml.system.err; int main(string[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual. I can honestly say, I don't know what dsfml is or any of the code you have posted. -Steve oh, it's ok because it's all work fine, I just was too inattentive.
[Issue 11961] Can't select CRT to link against
https://issues.dlang.org/show_bug.cgi?id=11961 --- Comment #4 from Manu--- Hooray!! --
[Issue 16673] New: improve cyclic module imports checker
https://issues.dlang.org/show_bug.cgi?id=16673 Issue ID: 16673 Summary: improve cyclic module imports checker Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: druntime Assignee: nob...@puremagic.com Reporter: c...@dawg.eu There are quite a few projects that broke b/c we fixed the cyclic module checker. We should try to relax the conservative import analysis. It seems that any static ctor/dtor only using symbols from the local module cannot produce cycles just b/c of that and thus be marked as standalone. Also cycles coming from imports in unittest blocks could possibly be ignored. [¹]: https://github.com/dlang/druntime/pull/1602 [²]: https://github.com/dlang/druntime/pull/1602#issuecomment-231527759 --
[Issue 11961] Can't select CRT to link against
https://issues.dlang.org/show_bug.cgi?id=11961 github-bugzi...@puremagic.com changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --
[Issue 11961] Can't select CRT to link against
https://issues.dlang.org/show_bug.cgi?id=11961 --- Comment #3 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/19b02322007c88a79648cc46f5732f50d42c77fd fix issue 11961: allow selecting the MS C runtime to link against https://github.com/dlang/dmd/commit/2c11a0241b88be6eb5416812188c2ca6df196916 Merge pull request #6244 from rainers/select_mscrtlib fix issue 11961: allow selecting the MS C runtime to link against --
Re: CTFE Status
On Tuesday, 8 November 2016 at 21:56:32 UTC, Stefan Koch wrote: I am onto the next bug. Let's hunt them all down! Marvellous!
Re: typeof(SortedRange) and is operator
On Tuesday, November 08, 2016 22:33:08 Era Scarecrow via Digitalmars-d-learn wrote: > On Tuesday, 8 November 2016 at 21:14:41 UTC, Jonathan M Davis > > wrote: > > No, as the others have point out, it's not a bug. If anything > > it's a language design flaw that no one has figured out how to > > resolve yet. > > The idea of a special struct for code that strips whitespace > out, or a function that simply does the same thing... Either way > it would have to be voluntary, preferably at the function level > writing and not the user level. > > StringNWS? (No White Space) or StringCode? > > Might be something to try... Having a function to call that > strips it would probably add too much overhead and ugliness > required by users using the code vs code clarity. > > I'll have to experiment with this later. The problem is that you can't strip out all whitespace. Some of it matters, and unless you do something like parse the code in the string, you can't know whether the whitespace matters or not. Ultimately, it's just easier to write your strings the same way, which usually is trivial. - Jonathan M Davis
Re: CTFE Status
On 11/08/2016 05:54 PM, Nick Sabalausky wrote: On 11/08/2016 02:30 PM, Patrick Schluter wrote: I describe git not as a vcs but as exacly what Linus Torvalds described it when he first presented it the Kernel mailing list: a directory content state recorder optimized for text files. ...that's incapable of comprehending the concept of empty directories, contrary to every major file system in use. I never bought the argument about "b/c it tracks content, not files". If that really did explain the limitation, then it wouldn't be capable of handling empty *files* either, and yet it does. (Pardon the OT)
Re: CTFE Status
On 11/08/2016 02:30 PM, Patrick Schluter wrote: I describe git not as a vcs but as exacly what Linus Torvalds described it when he first presented it the Kernel mailing list: a directory content state recorder optimized for text files. ...that's incapable of comprehending the concept of empty directories, contrary to every major file system in use. I never bought the argument about "b/c it tracks content, not files". If that really did explain the limitation, then it wouldn't be capable of handling empty *files* either, and yet it does.
Re: typeof(SortedRange) and is operator
On Tuesday, 8 November 2016 at 21:14:41 UTC, Jonathan M Davis wrote: No, as the others have point out, it's not a bug. If anything it's a language design flaw that no one has figured out how to resolve yet. The idea of a special struct for code that strips whitespace out, or a function that simply does the same thing... Either way it would have to be voluntary, preferably at the function level writing and not the user level. StringNWS? (No White Space) or StringCode? Might be something to try... Having a function to call that strips it would probably add too much overhead and ugliness required by users using the code vs code clarity. I'll have to experiment with this later.
Re: CTFE Status
Back to CTFE. The 64Bit bug is fixed. And now there is one bailout-line less. I am onto the next bug. Let's hunt them all down!
Re: CTFE Status
On Tuesday, 8 November 2016 at 16:40:31 UTC, Nick Sabalausky wrote: On 11/05/2016 11:48 AM, Marc Schütz wrote: On Saturday, 5 November 2016 at 01:21:48 UTC, Stefan Koch wrote: I recently lost 3 days of work because of my git-skills. Unless you haven't committed your work yet, almost everything in Git can be undone. Make a copy of your entire project directory (including .git) and then have a look at `git reflog` around the time the disaster happened. It will show you commit IDs that you can check out. Yea, but unless you're a git-fu master, sometimes figuring out how to fix whatever got messed up can lose you 3 days of work ;) I really want to make a saner CLI front-end for git, but that would require learning more about git than I really ever want to know :( http://gitless.com/
Re: typeof(SortedRange) and is operator
On Tuesday, November 08, 2016 13:22:35 RazvanN via Digitalmars-d-learn wrote: > Sorry, I accidentally posted the above message and I don't know > how to erase it. > The following post is the complete one: > > Given the following code: > > int[] arr = [1, 2, 9, 4, 10, 6]; > auto r= sort(arr); > > if(is(typeof(r) == SortedRange!(int[], "a writeln("first if"); > > if(is(typeof(r) == SortedRange!(int[], "a < b"))) > writeln("second if"); > > The program outputs only "second if". I assumed that it should > have printed both > ifs. Is this a bug? No, as the others have point out, it's not a bug. If anything it's a language design flaw that no one has figured out how to resolve yet. The big thing here is that lambdas in general are not comparable, even if they are _exactly_ the same. e.g. this will fail to compile int[] arr; auto r1 = sort!((a, b) => a < b)(arr); auto r2 = sort!((a, b) => a < b)(arr); static assert(typeof(r1) == typeof(r2)); You get an error like Error: static assert (is(SortedRange!(int[], __lambda1) == SortedRange! (int[], __lambda2))) is false It doesn't think that __lambda1 and __lambda2 are the same, and that's with two totally identical lambdas. The language and the compiler simply do not have a way to do a comparison of lambdas. It's probably possible to make them do it, but no one has figured out how to do it yet. String lambdas predate the lambda syntax that I used above, and they have largely been replaced by that new syntax. But string lambdas are still in use in part because it's possible to compare strings for equality, and therefore it's possible to compare string lambdas for equality. But even then, it's comparing strings for exact equality and not attempting to decipher the strings. Part of that is because string lambdas are actually using a library construct - std.functional.binaryFun in this case - in order to work, so the language is just comparing two instances of the same instantiation of a template for equality - e.g. binaryFun!"a < b" and binaryFun!"a < b", which would be equal, or binaryFun!"a < b" and binaryFun!"a
Re: ModuleInfo linker error when importing std.stdio and using package.d
Dne 8.11.2016 v 21:16 Bryce Kellogg via Digitalmars-d-learn napsal(a): ... Finally, a one line package.d: public import my_package.my_module; Change it to: module my_package; public import my_package.my_module; Btw, having class name same as module name is not best way, there could be some issues with that
ModuleInfo linker error when importing std.stdio and using package.d
Hi everyone, I'm new to D, and I'm trying to get a handle on the correct way to use packages, modules, and importing things. I created a simple example, but I'm getting linker errors in weird situations. I'm hoping to get some insight into why the error is happening and best practices in these sorts of situations. I've got a simple project set up as follows: . ├── dub.json └── source/ ├── app.d └── my_package/ ├── my_module.d └── package.d The contents of dub.json are pretty simple: { "name": "my_package_test", "description": "A minimal D application.", "copyright": "Copyright © 2016, kellogg", "authors": ["kellogg"], "dependencies": { } } In app.d, all I do is import my package and instantiate my class. import my_package; void main() { my_module m = new my_module(); } And here's my_module.d module my_package.my_module; import std.stdio; class my_module { this() { writeln("Hello World!"); } } Finally, a one line package.d: public import my_package.my_module; Building this via dub results in the error: .dub/obj/app.o:(.data._D3app12__ModuleInfoZ[_D3app12__ModuleInfoZ]+0x10): undefined reference to `_D10my_package12__ModuleInfoZ' collect2: error: ld returned 1 exit status Error: /usr/bin/gcc failed with status: 1 ldc2 failed with exit code 1. Interestingly, if I remove the 'import std.stdio;' and writeln() from my_module.d, it compiles fine. It also works if I move the import down to inside the constructor, or replace the import in app.d with 'import my_package.my_module;' (side stepping the package.d). To summarize: importing my package via package.d results in a linker error if I import std.stdio at the top level in my module. I'm wondering: what does this error mean, what does it have to do with std.stdio, and am I even using package.d correctly? Thanks!
Re: CTFE Status
On Tue, Nov 08, 2016 at 12:12:34PM -0500, Nick Sabalausky via Digitalmars-d wrote: > On 11/08/2016 11:57 AM, H. S. Teoh via Digitalmars-d wrote: > > > > The thing about git is that at its core, it's really very simple. > > Dumb, even. It's basically a program for managing a directed > > acyclic graph (DAG). That's all there is to it. The rest is just > > frills. > > > > Trying to rationalize git in terms of traditional version control > > systems is what usually causes lots of confusion, incomprehension, > > and frustration. To truly grok git, you have to just forget about > > traditional version control concepts, and think purely in terms of > > DAGs. Once you do, everything falls into place and it all makes > > sense in its own peculiar way (including all the flaws :-P). > > > > I don't suppose you have a handy link to an "Understanding Git as a > DAG manager instead of VCS" document? Nothing immediately comes to mind, but thanks to Dr. Google, I found this page that's sorta helpful: http://ericsink.com/vcbe/html/directed_acyclic_graphs.html And perhaps these: http://eagain.net/articles/git-for-computer-scientists/ http://marklodato.github.io/visual-git-guide/index-en.html Or maybe I should write my own article about git being based on a DAG. :-P T -- Leather is waterproof. Ever see a cow with an umbrella?
Re: CTFE Status
On Tuesday, 8 November 2016 at 16:57:27 UTC, H. S. Teoh wrote: On Tue, Nov 08, 2016 at 11:40:31AM -0500, Nick Sabalausky via Digitalmars-d wrote: On 11/05/2016 11:48 AM, Marc Schütz wrote: > On Saturday, 5 November 2016 at 01:21:48 UTC, Stefan Koch > wrote: > > > > I recently lost 3 days of work because of my git-skills. > > Unless you haven't committed your work yet, almost > everything in Git can be undone. Make a copy of your entire > project directory (including .git) and then have a look at > `git reflog` around the time the disaster happened. It will > show you commit IDs that you can check out. Yea, but unless you're a git-fu master, sometimes figuring out how to fix whatever got messed up can lose you 3 days of work ;) I really want to make a saner CLI front-end for git, but that would require learning more about git than I really ever want to know :( If you study carefully the data model of git you will then come to the conclusion that its CLI is not that bad. The thing about git is that at its core, it's really very simple. Dumb, even. It's basically a program for managing a directed acyclic graph (DAG). That's all there is to it. The rest is just frills. Trying to rationalize git in terms of traditional version control systems is what usually causes lots of confusion, incomprehension, and frustration. To truly grok git, you have to just forget about traditional version control concepts, and think purely in terms of DAGs. Once you do, everything falls into place and it all makes sense in its own peculiar way (including all the flaws :-P). I describe git not as a vcs but as exacly what Linus Torvalds described it when he first presented it the Kernel mailing list: a directory content state recorder optimized for text files. The DAG is already an abstraction above i.e. a mean to that end.
Re: CTFE Status
On Tuesday, 8 November 2016 at 17:12:34 UTC, Nick Sabalausky wrote: On 11/08/2016 11:57 AM, H. S. Teoh via Digitalmars-d wrote: [...] I don't suppose you have a handy link to an "Understanding Git as a DAG manager instead of VCS" document? Hi Nick, Maybe this one is useful for you: http://eagain.net/articles/git-for-computer-scientists/ Antonio
Re: Question about dsfml.system.err
On 11/8/16 11:48 AM, Konstantin Kutsevalov wrote: On Tuesday, 8 November 2016 at 16:34:04 UTC, Konstantin Kutsevalov wrote: ADD: I tried to open other stream in main() ``` ... import dsfml.system.err; int main(string[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual. I can honestly say, I don't know what dsfml is or any of the code you have posted. -Steve
Re: Why doesn't std.variant.visit automatically call the provided delegates?
On 11/5/16 4:22 PM, Adam D. Ruppe wrote: On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote: That feels like it should be a compiler warning. I'm now of the opinion that the {} delegates should be deprecated (instead use () {} delegates)... this comes up a lot and there's a few other places too where it is a pain... and it isn't that worth keeping imo. I created an enhancement request, as I didn't see any in the issue tracker already. https://issues.dlang.org/show_bug.cgi?id=16672 -Steve
[Issue 16670] std.variant visiting allows type parameters not held by variant
https://issues.dlang.org/show_bug.cgi?id=16670 --- Comment #1 from Nick Treleaven--- I have a fix working locally, will submit a PR soon. --
Re: Namespace for a module defined by its import path
On Tuesday, 8 November 2016 at 17:00:44 UTC, Jeff Thompson wrote: On Wednesday, 26 October 2016 at 17:12:30 UTC, Jonathan Marler wrote: On Wednesday, 26 October 2016 at 09:53:35 UTC, Jeff Thompson wrote: [...] I've thought about this and have concluded that you can't replicate these semantics in D. Here's 2 solutions though: [...] Right now, if a module doesn't have a package statement, the module name is the file name with the path and and extension stripped off. My problem would be solved by a compiler option to keep the path. ... or is there a way to get the path at compile time? I could try some mixin magic to construct the package name including the path.
[Issue 16670] std.variant visiting allows type parameters not held by variant
https://issues.dlang.org/show_bug.cgi?id=16670 Nick Treleavenchanged: What|Removed |Added Assignee|nob...@puremagic.com|n...@geany.org --
Re: CTFE Status
On 11/08/2016 11:57 AM, H. S. Teoh via Digitalmars-d wrote: The thing about git is that at its core, it's really very simple. Dumb, even. It's basically a program for managing a directed acyclic graph (DAG). That's all there is to it. The rest is just frills. Trying to rationalize git in terms of traditional version control systems is what usually causes lots of confusion, incomprehension, and frustration. To truly grok git, you have to just forget about traditional version control concepts, and think purely in terms of DAGs. Once you do, everything falls into place and it all makes sense in its own peculiar way (including all the flaws :-P). I don't suppose you have a handy link to an "Understanding Git as a DAG manager instead of VCS" document?
Re: What is the right level of abstractions for D?
On 11/07/2016 02:00 AM, Danni Coy via Digitalmars-d wrote: When I mean high quality I mean competitive with Qt (the current least bad cross platform toolkit), DLangUI gets compared to the Java UI offerings which leaves me somewhat cold. I have never met a java program with a UI I liked. Yea. DLangUI sounds nice and all to me, but the lack of native UI backend is a nonstarter. Have you tried QtE5? I admit I haven't had a chance to try it out yet myself, but from what I can tell, it looks like what I've been wanting in a D GUI lib: https://github.com/MGWL/QtE5 In the former case it might be nice to have some syntactic sugar in the way that maxscript does. for a in group where a.count > 0 do ( I know I'm not a group 3 person, but I find that difficult to read, and its similarity to SQL's undisciplined syntax frightens me. is easier to approach than foreach (a; group.filter!(a.count > 0)()) { but that is a fairly minor qwibble. I like to "stack" for/foreach/if's: foreach(group; setOfGroups) foreach(a; group) if(a.count > 0) { //... }
Re: CTFE Status
On Tue, Nov 08, 2016 at 11:40:31AM -0500, Nick Sabalausky via Digitalmars-d wrote: > On 11/05/2016 11:48 AM, Marc Schütz wrote: > > On Saturday, 5 November 2016 at 01:21:48 UTC, Stefan Koch wrote: > > > > > > I recently lost 3 days of work because of my git-skills. > > > > Unless you haven't committed your work yet, almost everything in Git > > can be undone. Make a copy of your entire project directory > > (including .git) and then have a look at `git reflog` around the > > time the disaster happened. It will show you commit IDs that you can > > check out. > > Yea, but unless you're a git-fu master, sometimes figuring out how to > fix whatever got messed up can lose you 3 days of work ;) > > I really want to make a saner CLI front-end for git, but that would > require learning more about git than I really ever want to know :( The thing about git is that at its core, it's really very simple. Dumb, even. It's basically a program for managing a directed acyclic graph (DAG). That's all there is to it. The rest is just frills. Trying to rationalize git in terms of traditional version control systems is what usually causes lots of confusion, incomprehension, and frustration. To truly grok git, you have to just forget about traditional version control concepts, and think purely in terms of DAGs. Once you do, everything falls into place and it all makes sense in its own peculiar way (including all the flaws :-P). T -- It only takes one twig to burn down a forest.
[Issue 16672] New: Deprecate "block only" delegate syntax
https://issues.dlang.org/show_bug.cgi?id=16672 Issue ID: 16672 Summary: Deprecate "block only" delegate syntax Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: schvei...@yahoo.com Currently, this code: {int x = 5; return x;} Can either be a block (if written by itself), or a delegate, if used in an expression. e.g.: auto dg = {int x = 5; return x;} This particular ambiguity becomes horrible if combined with the single expression lambda syntax: auto x = (a => {return a;})(1); What this looks like is an immediately called lambda that returns its parameter (a). However, what it *REALLY* returns is a delegate that will return 1 when called. This confusion leads to many problems, as people never want this result. The solution is simple -- deprecate the shortened brace syntax, and require () before the braces. e.g.: auto dg = () {int x = 5; return x; } Without the parens, the above should be an error. The drawback is obviously that one needs to insert parentheses wherever a no-param delegate needs declaring. The cost of doing this, IMO, is low compared to the regular reports we get of the x => {...} syntax "not working". --
Re: Namespace for a module defined by its import path
On Wednesday, 26 October 2016 at 17:12:30 UTC, Jonathan Marler wrote: On Wednesday, 26 October 2016 at 09:53:35 UTC, Jeff Thompson wrote: [...] I've thought about this and have concluded that you can't replicate these semantics in D. Here's 2 solutions though: [...] Right now, if a module doesn't have a package statement, the module name is the file name with the path and and extension stripped off. My problem would be solved by a compiler option to keep the path.
Re: Optimizing std.regex
On 11/8/16 12:23 PM, Chris wrote: On Monday, 7 November 2016 at 13:13:24 UTC, Mike Parker wrote: Dmitry mentioned here in the forums not long ago that he had squeezed some big performance improvements out of std.regex. His post on the D Blog describes how he managed to do it through an algorithmic optimization. The post: https://dlang.org/blog/2016/11/07/big-performance-improvement-for-std-regex/ Reddit: https://www.reddit.com/r/programming/comments/5bm1bc/from_the_d_blog_optimizing_stdregex/ Great job! Would it be possible (or indeed worth it) to create a similar engine for general text processing / string handling? Depends on what do you mean general - hard to find something more general then regex for text processing. Or do you mean using Bit NFA directly without the regex layer? It should be possible, however one needs to keep in mind the limitation - 32 or 64 states in total. --- Dmitry Olshansky
Re: Why doesn't std.variant.visit automatically call the provided delegates?
On 11/8/16 11:31 AM, Nick Sabalausky wrote: On 11/05/2016 04:22 PM, Adam D. Ruppe wrote: On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote: That feels like it should be a compiler warning. I'm now of the opinion that the {} delegates should be deprecated (instead use () {} delegates)... this comes up a lot and there's a few other places too where it is a pain... and it isn't that worth keeping imo. I didn't even know you could create a delegate with just {} and no parens. Kinda confusing since, normally, {} by itself creates a scope, not a delegate. Indeed: {int x = foo; return x;} // scope auto dg = {int x = foo; return x;} // delegate The requirements seem to be that you have to use the {} syntax as an expression instead of a block. omitting the initial parentheses seems like a really low benefit to having such confusing ambiguity. And of course, it leads to the horrible examples shown by OP. -Steve
Re: Question about dsfml.system.err
On Tuesday, 8 November 2016 at 16:34:04 UTC, Konstantin Kutsevalov wrote: ADD: I tried to open other stream in main() ``` ... import dsfml.system.err; int main(string[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module... OK ... problem with tcplistener solved, just a code mistake. But the question is actual.
[OT] Re: CTFE Status
On 11/05/2016 04:57 PM, Andrei Alexandrescu wrote: That's good thinking - leave short term to the short term and long term to the long term. As the Romanian proverb goes: "Don't sell the skin of the bear before you shoot it." -- Andrei I really wish Google would take that to heart. They seem to make a habit of ripping things out *before* having replacements in place. I think they just simply love deleting code.
Re: CTFE Status
On 11/05/2016 11:48 AM, Marc Schütz wrote: On Saturday, 5 November 2016 at 01:21:48 UTC, Stefan Koch wrote: I recently lost 3 days of work because of my git-skills. Unless you haven't committed your work yet, almost everything in Git can be undone. Make a copy of your entire project directory (including .git) and then have a look at `git reflog` around the time the disaster happened. It will show you commit IDs that you can check out. Yea, but unless you're a git-fu master, sometimes figuring out how to fix whatever got messed up can lose you 3 days of work ;) I really want to make a saner CLI front-end for git, but that would require learning more about git than I really ever want to know :(
Re: Question about dsfml.system.err
ADD: I tried to open other stream in main() ``` ... import dsfml.system.err; int main(string[] args) { err.open("errors.log", "a"); err.write("test\n"); } ... ``` but as can I see, that hasn't any effect for tcplistener module...
Re: Why doesn't std.variant.visit automatically call the provided delegates?
On 11/05/2016 04:22 PM, Adam D. Ruppe wrote: On Saturday, 5 November 2016 at 20:15:14 UTC, Kapps wrote: That feels like it should be a compiler warning. I'm now of the opinion that the {} delegates should be deprecated (instead use () {} delegates)... this comes up a lot and there's a few other places too where it is a pain... and it isn't that worth keeping imo. I didn't even know you could create a delegate with just {} and no parens. Kinda confusing since, normally, {} by itself creates a scope, not a delegate.
Question about dsfml.system.err
I need to see errors from dsfml.system.err, but it doesn't write to terminal as I expected. The general problem is that I cannot listen any port by tcplistener. And listen method is: Status accept(TcpSocket socket) { import dsfml.system.string; Status toReturn = sfTcpListener_accept(sfPtr, socket.sfPtr); err.write(dsfml.system.string.toString(sfErr_getOutput())); return toReturn; } so, as you can see, there is "err.write". I need to see which error is wrining ro "err"... Is it possible to redeclate "err" File() object? :(
Re: typeof(SortedRange) and is operator
On 11/08/2016 07:06 AM, RazvanN wrote: >> `SortedRange!(int[], "a> because the arguments to the templates differ i.e. "a> >> Is this a bug? no. is it weird, confusing and unintuitive? yes. > > I think that lambda comparison should be done logically (by that I mean: > what the function actually computes) not literally. Still, from the point of view of the language string template parameters are not necessarily lambdas. The fact that a particular template may mix them in and use in similar fashion cannot change it. > For example: it is a > mistake to consider the 2 two lambda functions different just because > one expression has more white spaces. Possibly but again, the language not necessarily knows what that string means. The whitespace my be significant. > Also "a < b" is the same lambda > function as "e < d"; considering these 2 functions to not be equal is a > mistake. So-called "string lambdas" are actually pretty weird. You know that "e < d" cannot work with SortedRange, right? The string is actually mixed-in; so you have to know what the surrounding code expects and provide a matching string. In this case, you have to provide 'a' and 'b'. Ali
Re: Trailing catch on function?
On 8 November 2016 at 12:50, Mike Parker via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On Tuesday, 8 November 2016 at 01:50:26 UTC, Walter Bright wrote: > >> On 11/7/2016 4:12 PM, Robert burner Schadek wrote: >> >>> On Monday, 7 November 2016 at 23:37:18 UTC, Walter Bright wrote: >>> void callback() nothrow { scope (failure) { ...log error or abort... } ...lots of code... } >>> >>> Who to get the Exception thrown in the scope(failure) >>> >> >> You don't. The exception is also rethrown, so it isn't an exact >> replacement. (The 'nothrow' is a mistake on my part.) >> > > In this specific case, a function used as a callback for a C API, it > really ought to be nothrow because of the inconsistent behavior with > propagating exceptions across language boundaries. scope(exit) just isn't > useful here. > It's not strictly useful for interaction with C, it would be equally useful in the situation where a nothrow function returns an error code or something. The tail-catch block could do the translation and return the error, and it would be in a nice place separate from the main function body.
Re: Trailing catch on function?
On 8 November 2016 at 09:37, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 11/6/2016 8:30 PM, Manu via Digitalmars-d wrote: > >> Hey people, I'm passing lots of D function pointers to C, and naturally, >> the C >> api expects the fp signatures are all nothrow. >> >> Which means, my D functions all look like this: >> >> void callback() nothrow >> { >> try >> { >> ...lots of code... >> } >> catch (Exception e) >> { >> ...log error or abort... >> } >> } >> >> >> I'm generally annoyed by all the extra indentation. >> > > void callback() nothrow > { > scope (failure) > { > ...log error or abort... > } > ...lots of code... > } > scope(failure) doesn't catch... how is that function nothrow?
Re: Thread (spawn) for object's method
On Tuesday, 8 November 2016 at 06:40:32 UTC, Basile B. wrote: On Monday, 7 November 2016 at 16:15:44 UTC, Konstantin Kutsevalov wrote: Is there a way to make new thread for class method? E.g. I have some class and I need to run one of them method in new thread. I found wxamples only with function... import core.thread; class Foo { void method(){} } void main() { Foo foo = new Foo; Thread t = new Thread(); } oh, so simple... :) thank you!
Re: Is the following code legal?
no
Re: how to debug memory errors
On Tuesday, 8 November 2016 at 14:55:53 UTC, Steven Schveighoffer wrote: Indeed, you should not. I'm saying this type of error can explain the observed behavior. The original post I responded to said "I don't know if the double free problem is related to this." -Steve Okay. I thought maybe there was a gotcha that I wasn't aware of.
Re: typeof(SortedRange) and is operator
On Tuesday, 8 November 2016 at 13:59:19 UTC, Nicholas Wilson wrote: On Tuesday, 8 November 2016 at 13:22:35 UTC, RazvanN wrote: Sorry, I accidentally posted the above message and I don't know how to erase it. You can't, this is a mailing list not a forum. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a expression` lambdas don't work at all in template expressions. `SortedRange!(int[], "a
Re: how to debug memory errors
On 11/8/16 6:26 AM, bachmeier wrote: On Monday, 7 November 2016 at 02:22:35 UTC, Steven Schveighoffer wrote: Imagine a resource wrapper like so: class Foo { int *mem; this() { mem = cast(int *)malloc(int.sizeof); } ~this() { .free(mem); } } Now, you have a problem if you do something like this: class Bar { Foo foo; ~this() { delete foo; } } Is there a valid use case for something like this? Why would you want to do anything inside ~this with GC memory? Indeed, you should not. I'm saying this type of error can explain the observed behavior. The original post I responded to said "I don't know if the double free problem is related to this." -Steve
Re: Array operation with overlapping
On 11/8/16 3:29 AM, Oleg Gorbunov wrote: I am new in D, but saw some strage behavour. Overlapping is detected for + and * array operation, but not for - and /. I would say this is a bug. The behavior should be consistent. -Steve
Re: Is the following code legal?
On 11/8/16 7:58 AM, Shachar Shemesh wrote: SomeStruct[int] aa; SomeStruct* aap = v in aa; aa.remove(v); writeln(aap); It currently will work. At some point in the past, this did NOT work, as we were proactively freeing the data. I don't know if the policy is that this is officially supported or not. Hence, I don't know the answer to the question "is it legal". -Steve
Re: typeof(SortedRange) and is operator
On Tuesday, 8 November 2016 at 13:59:19 UTC, Nicholas Wilson wrote: You can't, this is a mailing list not a forum. > forum.dlang.org
Re: typeof(SortedRange) and is operator
On Tuesday, 8 November 2016 at 13:22:35 UTC, RazvanN wrote: Sorry, I accidentally posted the above message and I don't know how to erase it. You can't, this is a mailing list not a forum. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a expression` lambdas don't work at all in template expressions. `SortedRange!(int[], "a
Re: calling convention optimisation & const/immutable ref
On Tuesday, 8 November 2016 at 12:56:10 UTC, Johan Engelen wrote: On Monday, 7 November 2016 at 16:48:55 UTC, John Colvin wrote: [...] This reminds me of an LLVM presentation by Chandler, mentioning that passing by reference may hamper the optimization of code (because memory becomes involved). I don't think he gave a clear example, but one thing I can think of is potential aliasing: void foo(ref LargeThing a, ref LargeThing b), where a and b may alias partly. To do the "ref" optimization for _all_ large function parameters per default sounds like a bad idea. Also, how would I turn the optimization off (I guess extern(C++) would do that?)? What if my function needs a local copy (say, in multithreaded stuff), and I want that copy to be const? -Johan Aliasing is not an issue when LargeThing is immutable, is it ?
Re: typeof(SortedRange) and is operator
Sorry, I accidentally posted the above message and I don't know how to erase it. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a
typeof(SortedRange) and is operator
Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto r= sort(arr); if(is(typeof(r) == SortedRange!(int[], "a
Re: Is the following code legal?
On 08/11/16 14:58, Shachar Shemesh wrote: SomeStruct[int] aa; ... SomeStruct* aap = v in aa; aa.remove(v); writeln(aap); That last line is, of course: "writeln(*aap);" Shachar
Is the following code legal?
SomeStruct[int] aa; ... SomeStruct* aap = v in aa; aa.remove(v); writeln(aap);
Re: calling convention optimisation & const/immutable ref
On Monday, 7 November 2016 at 16:48:55 UTC, John Colvin wrote: Some people use ref for performance to prevent the copying that must occur when passing by value. This reminds me of an LLVM presentation by Chandler, mentioning that passing by reference may hamper the optimization of code (because memory becomes involved). I don't think he gave a clear example, but one thing I can think of is potential aliasing: void foo(ref LargeThing a, ref LargeThing b), where a and b may alias partly. To do the "ref" optimization for _all_ large function parameters per default sounds like a bad idea. Also, how would I turn the optimization off (I guess extern(C++) would do that?)? What if my function needs a local copy (say, in multithreaded stuff), and I want that copy to be const? -Johan
[Issue 14511] Profiler does not work with multithreaded programs
https://issues.dlang.org/show_bug.cgi?id=14511 Alexchanged: What|Removed |Added CC||sascha.or...@gmail.com --- Comment #6 from Alex --- After an update from 2.071.2 to 2.072.0 a seg fault with the profile option on a mac appear with the following example void main() {} void f() { import core.atomic: atomicOp; shared size_t workUnitIndex; atomicOp!"+="(workUnitIndex, 1); } which does not appear with the prior version of atomic.d Many thanks to ag0aep6g for helping with the code. --
Re: how to debug memory errors
On Tuesday, 8 November 2016 at 11:53:37 UTC, Era Scarecrow wrote: On Tuesday, 8 November 2016 at 11:26:55 UTC, bachmeier wrote: Is there a valid use case for something like this? Why would you want to do anything inside ~this with GC memory? If we assume it's a C++ attachment/library/object using different memory allocation? I'm not sure what "it's" is referring to in your statement. In the example, Foo wraps manually allocated memory that is freed when Foo goes out of scope. If the goal is to free the memory in Foo when Bar goes out of scope, that can be done without error by rewriting Foo. Therefore I'm not understanding how this situation can arise in real world code (I'm sure it can, though, which is why I'm asking).
[Issue 16671] std.variant visiting functions should pass file, line to VariantException
https://issues.dlang.org/show_bug.cgi?id=16671 Nick Treleavenchanged: What|Removed |Added Keywords||pull URL||https://github.com/dlang/ph ||obos/pull/4892 --
[Issue 16671] New: std.variant visiting functions should pass file, line to VariantException
https://issues.dlang.org/show_bug.cgi?id=16671 Issue ID: 16671 Summary: std.variant visiting functions should pass file, line to VariantException Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: n...@geany.org When Algebraic().visit (or tryVisit) throws an exception, the file and line number are always internal to std.variant. It should use the caller's __FILE__, __LINE__. --
Re: how to debug memory errors
On Tuesday, 8 November 2016 at 11:26:55 UTC, bachmeier wrote: Is there a valid use case for something like this? Why would you want to do anything inside ~this with GC memory? If we assume it's a C++ attachment/library/object using different memory allocation?
[Issue 16670] New: std.variant visiting allows type parameters not held by variant
https://issues.dlang.org/show_bug.cgi?id=16670 Issue ID: 16670 Summary: std.variant visiting allows type parameters not held by variant Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: n...@geany.org Algebraic!(size_t, string) variant; variant.visit!((void*)=>0, (size_t s)=>0, (string s)=>0); variant.tryVisit!((void*)=>0); variant.tryVisit!((bool)=>0); None of the 3 visiting functions should compile because `variant` can't hold void* or bool. Should be statically prevented to catch bugs. --
Re: Trailing catch on function?
On Tuesday, 8 November 2016 at 11:24:59 UTC, Anonymouse wrote: You can eat the exception by returning in the scope guard. Since it seems to trigger on Throwables it also eats Errors, sadly. Interesting! Considering this works: scope(failure) { abort(); return; } I had expected this to work also: scope(failure) abort(); But I guess D lacks support for noreturn attribute on abort?
RCString Time frame
I'm planning to rewrite / improve some of my text handling modules. Before I do so, however, I'd like to know when RCString will be introduced (roughly)? And how will it handle Unicode, or auto-decode to be precise. As far as I remember, RCString wants to get rid of it.
Re: "Multiple alias this" status?
Thank you for your answer, that is a sad news.
Re: how to debug memory errors
On Monday, 7 November 2016 at 02:22:35 UTC, Steven Schveighoffer wrote: Imagine a resource wrapper like so: class Foo { int *mem; this() { mem = cast(int *)malloc(int.sizeof); } ~this() { .free(mem); } } Now, you have a problem if you do something like this: class Bar { Foo foo; ~this() { delete foo; } } Is there a valid use case for something like this? Why would you want to do anything inside ~this with GC memory?
Re: Optimizing std.regex
On Monday, 7 November 2016 at 13:13:24 UTC, Mike Parker wrote: Dmitry mentioned here in the forums not long ago that he had squeezed some big performance improvements out of std.regex. His post on the D Blog describes how he managed to do it through an algorithmic optimization. The post: https://dlang.org/blog/2016/11/07/big-performance-improvement-for-std-regex/ Reddit: https://www.reddit.com/r/programming/comments/5bm1bc/from_the_d_blog_optimizing_stdregex/ Great job! Would it be possible (or indeed worth it) to create a similar engine for general text processing / string handling?
Re: Trailing catch on function?
On Tuesday, 8 November 2016 at 01:50:26 UTC, Walter Bright wrote: Who to get the Exception thrown in the scope(failure) You don't. The exception is also rethrown, so it isn't an exact replacement. (The 'nothrow' is a mistake on my part.) You can eat the exception by returning in the scope guard. Since it seems to trigger on Throwables it also eats Errors, sadly. void fun() nothrow { scope(failure) { // cleanup logic return; } throw new Exception("I don't get rethrown"); }
Re: calling convention optimisation & const/immutable ref
On Monday, 7 November 2016 at 16:48:55 UTC, John Colvin wrote: Some people use ref for performance to prevent the copying that must occur when passing by value. I propose a small optimisation to make this unnecessary in a bunch of cases. At the ABI level (no change in language semantics), if a given parameter would otherwise be copied and passed on the stack: 1) immutable parameters to all functions are passed by reference 2) const parameters to pure functions are passed by reference, if and only if all other parameters - including any implicit this parameter - contain no mutable references (otherwise "weakly" pure functions could modify the data we are now referring to instead of having copied, changing semantics). If this is done, it should only apply to parameters larger than a certain size, say 2 words. Indirect memory access comes with its own cost that is often larger than that of copying.
Re: "Multiple alias this" status?
Dne 8.11.2016 v 11:37 Picaud Vincent via Digitalmars-d napsal(a): Hi All, I just started to learn a little bit of D. I read this thread https://github.com/dlang/dmd/pull/3998 about "Multiple alias this". I think this feature is very handy, but dmd and gcd compilers complain that "there must be only one" alias this. It is not clear to me if this feature is not available yet or if there was a change in the language specifications (Andrei Alexandrescu book mentions "§6.13 Multiple subtyping") ? Does anyone has more information concerning that? Thanks in advance, Vincent This feature has never been part of any D compiler. As you can see there is a pull request 3998 which trying to add this to D frontend, but there is no activity for a few months.
Re: New to D and mimicking C++ : how to implement std::integral_constant<>?
Hi Basile, Thank you for your code, it allowed me to grasp a little bit more about how to do things in D. Vincent
"Multiple alias this" status?
Hi All, I just started to learn a little bit of D. I read this thread https://github.com/dlang/dmd/pull/3998 about "Multiple alias this". I think this feature is very handy, but dmd and gcd compilers complain that "there must be only one" alias this. It is not clear to me if this feature is not available yet or if there was a change in the language specifications (Andrei Alexandrescu book mentions "§6.13 Multiple subtyping") ? Does anyone has more information concerning that? Thanks in advance, Vincent
Re: Trailing catch on function?
On Tuesday, 8 November 2016 at 01:50:26 UTC, Walter Bright wrote: You don't. The exception is also rethrown, so it isn't an exact replacement. (The 'nothrow' is a mistake on my part.) this: scope(failure, Exception e) { // Do something with e } would be nice
Re: how to debug memory errors
On Tuesday, 8 November 2016 at 07:39:12 UTC, Era Scarecrow wrote: On Tuesday, 8 November 2016 at 06:04:59 UTC, thedeemon wrote: On Tuesday, 8 November 2016 at 05:36:22 UTC, Era Scarecrow wrote: Hmmm.. I had the impression that if something was referenced by another object, then it couldn't be collected, Another *live* object, I.e. reachable from globals and stack. If you have a big tree and it becomes unreachable (you only had a pointer to its root and you nulled it), then this whole tree becomes garbage, and its nodes and leafs will be collected in unpredictable order, with destructors being run in unpredictable order, even when these dead nodes reference each other. And I can't help but hope it would start at the largest/base object and work it's way up. Or the largest object and then work it's way down. Alright... One of the reasons it is not specified is that very often the hierarchy is not a simple tree, but a graph with possibly many cycles. As a matter of fact, very often child nodes have pointers to parent nodes, so that what is logically a tree is practically a graph with lots of cycles. So it is not possible to identify a root object which does not have incoming dead pointers, and no guarantee can be provided.
Array operation with overlapping
I am new in D, but saw some strage behavour. Overlapping is detected for + and * array operation, but not for - and /. import std.stdio; void main() { int[] slice = [2, 2, 2, 2]; int[] slice2 = slice[0 .. $ - 1]; int[] slice3 = slice[1 .. $]; writeln("slice before: ", slice); writeln("slice2 before: ", slice2); writeln("slice3 before: ", slice3); const auto cmd = "slice3[] = slice2[] + slice3[];"; writeln( "cmd: ", cmd ); mixin( cmd ); writeln("slice after : ", slice); writeln("slice2 after : ", slice2); writeln("slice3 after : ", slice3); } When this code is run at 'dlang.org' slice before: [2, 2, 2, 2] slice2 before: [2, 2, 2] slice3 before: [2, 2, 2] cmd: slice3[] = slice2[] + slice3[]; object.Error@(0): Overlapping arrays in vector operation: 8 byte(s) overlap of 12 ??:? nothrow @safe void rt.util.array._enforceNoOverlap(const(char[]), ulong, ulong, const(ulong)) [0x44f7f3] ??:? _arraySliceSliceAddSliceAssign_i [0x44c1b6] ??:? _Dmain [0x4408bb] ??:? _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv [0x44c8a6] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c7f0] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll() [0x44c862] ??:? void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x44c7f0] ??:? _d_run_main [0x44c761] ??:? main [0x44a389] ??:? __libc_start_main [0x40d80a14] If change + to - const auto cmd = "slice3[] = slice2[] - slice3[];"; When it is run at 'dlang.org' slice before: [2, 2, 2, 2] slice2 before: [2, 2, 2] slice3 before: [2, 2, 2] cmd: slice3[] = slice2[] - slice3[]; slice after : [2, 0, -2, -4] slice2 after : [2, 0, -2] slice3 after : [0, -2, -4]