Re: GC question

2017-02-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/02/2017 5:02 PM, thedeemon wrote: snip It may look so from a distance. But in my experience it's not that bad. In most software I did in D it did not matter really (it's either 64-bit or short lived programs) and the control D gives to choose how to deal with everything makes it all quite

Re: GC question

2017-02-04 Thread thedeemon via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: - Automatic but conservative. Can leak at any time. You have to implement manual management (managed heaps) to avoid leaks. Leaks are hard to find as any heap value may be causing it. By "managed heap" I just meant the GC heap, the one

Re: Is there anything fundamentally wrong with this code?

2017-02-04 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 3 February 2017 at 18:37:15 UTC, Johan Engelen wrote: The error is in this line. Instead of assigning to the `postProc` at module scope, you are defining a new local variable and assigning to it. Wasn't the compiler suppose to warn you when you are shadowing another variable? Or i

Re: "template with auto ref" experiment

2017-02-04 Thread Alex via Digitalmars-d-learn
On Saturday, 4 February 2017 at 16:18:00 UTC, kinke wrote: It most likely only works because the dangling pointer points into yet untouched stack. Trying to öet a normal by-value parameter or local variable escape this way should produce an error, but apparently it's not done for `auto ref` p

Re: "template with auto ref" experiment

2017-02-04 Thread Alex via Digitalmars-d-learn
On Saturday, 4 February 2017 at 16:53:13 UTC, Ali Çehreli wrote: If you haven't already, you may want to read a recent thread as well: http://forum.dlang.org/post/jsksamnatzkshldnn...@forum.dlang.org Thanks for the instructive link...

Re: Can't iterate over range

2017-02-04 Thread ag0aep6g via Digitalmars-d-learn
On 02/04/2017 03:53 PM, Profile Anaysis wrote: well, I simply took the code from the page I linked and did a front() on the MapResult and it say the type was wrong. I thought it would give me the type I put in which was an array. In the code you can see that powerSet does two levels of `map`. I

Re: "template with auto ref" experiment

2017-02-04 Thread Ali Çehreli via Digitalmars-d-learn
On 02/04/2017 06:33 AM, Alex wrote: > whether I'm doing something unsecure... If you haven't already, you may want to read a recent thread as well: http://forum.dlang.org/post/jsksamnatzkshldnn...@forum.dlang.org In addition to valuable information by others there, I tried to argue that e

Re: "template with auto ref" experiment

2017-02-04 Thread kinke via Digitalmars-d-learn
On Saturday, 4 February 2017 at 14:33:12 UTC, Alex wrote: Having read this https://dlang.org/spec/template.html#auto-ref-parameters I tried to do something like this // Code starts here void main() { initStruct iSb; iSb.var = 3; A b = A(iSb); assert(*b.myVar == 3

Re: GC question

2017-02-04 Thread osa1 via Digitalmars-d-learn
All GCs are prone to leak, including precise ones. The point of garbage collection is not to prevent leaks, but rather to prevent use-after-free bugs. Of course I can have leaks in a GC environment, but having non-deterministic leaks is another thing, and I'd rather make sure to delete my ref

Re: Is there anything fundamentally wrong with this code?

2017-02-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2017 at 14:37:45 UTC, aberba wrote: Most D devs ignore the "this" in their code and that has influenced me to do that often. Is it no prone to bugs? I actually usually use `this` now exactly to be explicit against this kind of thing.

Re: GC question

2017-02-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: - Automatic but conservative. Can leak at any time. All GCs are prone to leak, including precise ones. The point of garbage collection is not to prevent leaks, but rather to prevent use-after-free bugs. Granted, the D 32 bit GC is mo

Re: Can't iterate over range

2017-02-04 Thread Profile Anaysis via Digitalmars-d-learn
On Saturday, 4 February 2017 at 14:35:37 UTC, ag0aep6g wrote: On 02/04/2017 12:31 PM, Profile Anaysis wrote: I am trying to iterate over the combinations of a set using the code https://rosettacode.org/wiki/Power_set#D I have an array which I call powerSet on and I get a result of MapResult.

Re: Is there anything fundamentally wrong with this code?

2017-02-04 Thread aberba via Digitalmars-d-learn
On Friday, 3 February 2017 at 22:34:31 UTC, Ali Çehreli wrote: On 02/03/2017 11:43 AM, WhatMeWorry wrote: On Friday, 3 February 2017 at 18:37:15 UTC, Johan Engelen wrote: On Friday, 3 February 2017 at 17:20:43 UTC, WhatMeWorry wrote: [...] ... Another related one is assigning to a par

Re: Can't iterate over range

2017-02-04 Thread ag0aep6g via Digitalmars-d-learn
On 02/04/2017 12:31 PM, Profile Anaysis wrote: I am trying to iterate over the combinations of a set using the code https://rosettacode.org/wiki/Power_set#D I have an array which I call powerSet on and I get a result of MapResult. I have tried to foreach or front/popFront and even each() on it

"template with auto ref" experiment

2017-02-04 Thread Alex via Digitalmars-d-learn
Having read this https://dlang.org/spec/template.html#auto-ref-parameters I tried to do something like this // Code starts here void main() { initStruct iSb; iSb.var = 3; A b = A(iSb); assert(*b.myVar == 3); // this works iSb.var = 4; assert(*b.myV

Re: GC question

2017-02-04 Thread Kagamin via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: I'm surprised that D was able to come this far with this. It's used mostly for server software. Things are moving to 64 bit, so this will be less of an issue.

Re: GC question

2017-02-04 Thread osa1 via Digitalmars-d-learn
On Saturday, 4 February 2017 at 11:09:21 UTC, thedeemon wrote: On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conservative GC bef

Re: module specification for variables

2017-02-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 February 2017 at 09:31:57 UTC, Profile Anaysis wrote: module x; special int X; // special = some keyword that makes this work as I intend. e.g., "no_import int X;" module y; void main() { import x; x.X = 3; // X = 3; fails. } extern(C) int X;

Re: Can you read the next line while iterating over byLine?

2017-02-04 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 4 February 2017 at 08:54:27 UTC, Ivan Kazmenko wrote: On Thursday, 2 February 2017 at 19:34:37 UTC, John Doe wrote: Thanks readln is perfect. Since I am calling readln in different places and I always need to remove the newline character I have line=line[0..$-1] all over my code. I

Re: The reason of vibed slow down (request timeout)

2017-02-04 Thread Suliman via Digitalmars-d-learn
On Friday, 3 February 2017 at 07:44:15 UTC, crimaniak wrote: On Friday, 3 February 2017 at 06:46:37 UTC, Suliman wrote: If I open it's from VPS (as localhost:8080) it's work same as from Internet (no do not open at all). If problem is reproducible on localhost - very good, just debug it. If y

Can't iterate over range

2017-02-04 Thread Profile Anaysis via Digitalmars-d-learn
I am trying to iterate over the combinations of a set using the code https://rosettacode.org/wiki/Power_set#D I have an array which I call powerSet on and I get a result of MapResult. I have tried to foreach or front/popFront and even each() on it but I can never get the result as the same ar

Re: GC question

2017-02-04 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conservative GC before. Are there any disallowed memory operations? Can I break thi

Re: Fiber overhead

2017-02-04 Thread Suliman via Digitalmars-d-learn
On Saturday, 4 February 2017 at 06:54:01 UTC, Ali Çehreli wrote: On 02/03/2017 08:47 PM, Profile Anaysis wrote: What is the overhead of using a fiber? The performance overhead of call() and yield() are comparable to function calls because it's simply a few register assignments in each case.

module specification for variables

2017-02-04 Thread Profile Anaysis via Digitalmars-d-learn
I'd like to have a global variable in a module but it must be accessed by the module name outside of the module. Sort of like a static variable in a class. private blocks it completely and public will allow it to be imported in to the global scope. Haven't tried protected but I assume that is

Re: Can you read the next line while iterating over byLine?

2017-02-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 2 February 2017 at 19:34:37 UTC, John Doe wrote: Thanks readln is perfect. Since I am calling readln in different places and I always need to remove the newline character I have line=line[0..$-1] all over my code. Is there are better way? "readln.strip" gives the line without the