Re: problem with gc?

2015-05-27 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 05:48:13 UTC, zhmt wrote: What happened when the code changes a little? Who will give an explaination,Thanks a lot? Yes, on the first sight it looks like your allocations in the loop make GC spend too much time. I don't think "scope" does anything here. Try addin

Re: How to implement immutable ring buffer?

2015-05-27 Thread thedeemon via Digitalmars-d-learn
This whole idea sounds self-contradictory. Ring buffer is a mutable-array-based implementation of something, for example of a queue. You can ask about immutable implementations of a queue, but that would be another question, not involving a ring buffer. What do you want to do with this buffer

Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn
On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote: I'm currently investigating the difference of speed between references and copies. And it seems that copies got a immense slowdown if they reach a size of >= 20 bytes. This is processor-specific, on different models of CPUs you might get d

Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn
On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote: Ah, actually it's more complicated, as it depends on inlining a lot. Indeed, without -O and -inline I was able to get by_ref to be slightly slower than by_copy for struct of 4 ints. But when inlining turns on, the numbers change in differen

Re: drastic slowdown for copies

2015-05-29 Thread thedeemon via Digitalmars-d-learn
On Friday, 29 May 2015 at 07:51:31 UTC, thedeemon wrote: Above was on Core 2 Quad, here's for Core i3: 4 ints 5 ints -release by ref: 67 by ref: 66 by copy: 44 by copy: 142 by move: 45 by move: 137 -release -O by ref: 29 by ref: 29 by copy: 41 by copy: 141 by mov

Re: using D without GC

2015-06-07 Thread thedeemon via Digitalmars-d-learn
On Sunday, 7 June 2015 at 10:23:22 UTC, Rikki Cattermole wrote: Don't worry about collecting at the end. The OS will clean up the app no matter what. Actually D runtime will also do a collection before exiting. This is why it shows "Number of collections: 2" above. One triggered manually, on

Re: DFL background tasks

2015-06-08 Thread thedeemon via Digitalmars-d-learn
On Sunday, 7 June 2015 at 13:34:59 UTC, Scroph wrote: I tried your code and it did work, however it still froze the UI while it was retrieving the data. Sure, because now you do your long operation in the UI thread. What happens in the delegate passed to invoke() happens in the main UI thread

Re: DFL background tasks

2015-06-08 Thread thedeemon via Digitalmars-d-learn
A more general and proper approach is to use message passing from std.concurrency. With DFL it looks like this: you spawn() a thread and don't pass any GUI controls to it, just thisTid (identifier of your main UI thread). In that worker tread when you've got some data to show in the UI (be it e

Re: DFL background tasks

2015-06-08 Thread thedeemon via Digitalmars-d-learn
On Monday, 8 June 2015 at 07:45:28 UTC, Ali Çehreli wrote: > receiveTimeout(dur!"msecs"(0). UFCS makes durations more pleasant: :) receiveTimeout(0.msecs) Oh, thanks! I missed this bit. This is much nicer!

Re: DFL background tasks

2015-06-10 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 10 June 2015 at 22:18:21 UTC, Scroph wrote: client.perform; while(!client.isStopped) I don't think this will work as you expect. "perform" is a synchronous call, it will not return until the download finishes, as I understand, so your while loop is too late. I th

Re: More type-flexible arrays?

2015-06-16 Thread thedeemon via Digitalmars-d-learn
On Sunday, 14 June 2015 at 06:12:30 UTC, Ozan wrote: Is it possible to create arrays which has more then one type, f. ex. array[0] = 1; array[1] = "z"; array[2] = new clazz(), Probably tuples are what you really need here. http://dlang.org/phobos/std_typecons.html#.Tuple

Re: incorrect data when returning static array in place of dynamic

2015-07-05 Thread thedeemon via Digitalmars-d-learn
On Sunday, 5 July 2015 at 18:57:46 UTC, sigod wrote: Why does function return incorrect data? Using `.dup` in return expression or using `ubyte[20]` as return type fixes problem, but why? Because sha1Of() returns ubyte[20], this is a stack-allocated array, a value type. If you put correct ret

Re: Thread communication

2015-08-05 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 15:19:51 UTC, Chris wrote: I want to stop (and abort) the worker as soon as new input arrives. However, while executing the function that contains the foreach-loop the worker thread doesn't listen, because it's busy, of course. I think this is a matter of archite

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 09:51:47 UTC, anonymous wrote: Huh. I think func being a template is the key here. When the original code is put in a template, it works too (with 2.068): Nope, it "works" only because "r" is unreferenced and gets thrown out. Just try using r.front there, for examp

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:38:05 UTC, anonymous wrote: auto func()(uint[] arr, uint delegate(uint) pure @nogc d) @nogc { return arr.map!(d); } void main() @nogc { uint[3] arr = [1,2,3]; uint context = 2; auto c = Caller(context); auto d = &c.method; auto r = func(ar

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote: I've just checked with my runtime GC hook. Here the call to func() allocates 12 bytes via gc_malloc, and it's the same for a 4-elements array, so it's not for the array itself, it's for a closure, I think. Also, compiling with -vgc s

Re: Getting a TypeTuple of a Template's Arguments

2015-08-18 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 21:23:49 UTC, Meta wrote: For functions, we have std.traits.ParameterTypeTuple. Is there any equivalent functionality for templates? I've recently searched for this thing and haven't found anything for uninstantiated templates, only for instantiated.

Re: GC and MMM

2015-08-20 Thread thedeemon via Digitalmars-d-learn
On Thursday, 20 August 2015 at 17:13:33 UTC, Ilya Yaroshenko wrote: Hi All! Does GC scan manually allocated memory? Only if you ask GC to do it - by calling core.memory.addRange.

Re: interprocess communication and sharing memory

2015-09-03 Thread thedeemon via Digitalmars-d-learn
On Thursday, 3 September 2015 at 02:52:00 UTC, Laeeth Isharc wrote: On Thursday, 3 September 2015 at 01:27:15 UTC, j55 wrote: This is my first attempt at a project in D, so pardon me if I'm overlooking something obvious: I'm using libasync to create an eventloop, to set up something like a se

Re: Working Windows GUI library?

2015-09-03 Thread thedeemon via Digitalmars-d-learn
On Thursday, 3 September 2015 at 15:46:28 UTC, Andre Polykanine wrote: So my question is: is there any reliable GUI library implementing native Windows controls? Yes, DFL! https://github.com/Rayerd/dfl It's a thin wrapper over WinAPI so all controls are native. I've built several apps wit

Re: Working Windows GUI library?

2015-09-04 Thread thedeemon via Digitalmars-d-learn
On Friday, 4 September 2015 at 13:54:25 UTC, Andre Polykanine wrote: Hello thedeemon, tvDdl> Yes, DFL! tvDdl> https://github.com/Rayerd/dfl Sounds good. but still... I can't find any examples or documentation :( Here's some original docs and examples: http://wiki.dprogramming.com/Dfl/Tutor

Re: spawn X different workers & wait for results from all of them

2015-09-05 Thread thedeemon via Digitalmars-d-learn
On Thursday, 3 September 2015 at 16:50:21 UTC, Robert M. Münch wrote: Hi, I'm not sure how to best implement the following: 1. I have 4 different tasks to do. 2. All can run in parallel 3. Every task will return some result that I need Now how to best do it? I think the Task and taskPool from

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-22 Thread thedeemon via Digitalmars-d-learn
On Monday, 21 September 2015 at 15:00:24 UTC, ponce wrote: All in the title. DMD 64-bit links with the VS linker. Do users need to install the VS redistributable libraries? I think they don't. Generated .exe seems to depend only on kernel32.dll and shell32.dll, i.e. things users already have.

Re: Can I check if a value is convertible to a valid value of an enum?

2015-09-24 Thread thedeemon via Digitalmars-d-learn
On Friday, 25 September 2015 at 03:12:20 UTC, French Football wrote: ...without having to loop over the enum? writeln( test( valid_value ) ); //prints true Since `value` is known only at run time, some checks need to be performed at run time anyway. One way of doing it without iterating o

Re: D code optimization

2016-09-22 Thread thedeemon via Digitalmars-d-learn
On Thursday, 22 September 2016 at 16:09:49 UTC, Sandu wrote: const int n = 252; double[] call = new double[n+1]; ... //delete call; // since D is has a garbage collector, explicit deallocation of arrays is not necessary. If you care about speed, better unco

Re: how to debug memory errors

2016-11-07 Thread thedeemon via Digitalmars-d-learn
On Monday, 7 November 2016 at 02:22:35 UTC, Steven Schveighoffer wrote: OP: it's not legal to destroy or even access GC allocated members in a destructor. The GC may have already destroyed that data. Isn't destroy() fine there? It doesn't call destructors for already destroyed objects, so I g

Re: how to debug memory errors

2016-11-07 Thread thedeemon via Digitalmars-d-learn
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

Re: Memory allocation failed. Why?

2016-11-21 Thread thedeemon via Digitalmars-d-learn
On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: core.exception.OutOfMemoryError@src\core\exception.d(693): Memory allocation failed Simple program and error. Why? Windows 7 (32) dmd 2.072.0 Making a 100 million bytes array by appending one byte at

Re: Impressed with Appender - Is there design/implementation description?

2016-12-06 Thread thedeemon via Digitalmars-d-learn
On Sunday, 4 December 2016 at 20:03:37 UTC, Jon Degenhardt wrote: I've been using Appender quite a bit recently, typically when I need append-only arrays with variable and unknown final sizes. I had been prepared to write a custom data structure when I started using it with large amounts of dat

Re: Auto recursive function

2017-01-12 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu wrote: Hi, I am currently trying to create a function makeMultidimensionalArray which allocates memory for a multidimensional array. You were very close to the answer: auto makeMultidimensionalArray(int N, T, Allocator)(auto ref Al

Re: writeln and ~

2017-01-14 Thread thedeemon via Digitalmars-d-learn
On Saturday, 14 January 2017 at 17:42:05 UTC, Ignacious wrote: writeln(x ~ " ok"); Just write writeln(x, " ok"); Any number of arguments, no unnecessary allocations. Do you really need ~?

Re: Thread will get garbage collected?

2017-01-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 16 January 2017 at 22:08:56 UTC, JN wrote: Am I correctly understanding, that after going out of scope, it's possible for GC to destroy my thread before the file finishes loading? How to prevent GC from destroying my thread before it finishes and make sure the file is loaded complet

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: 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: Serializer class

2017-02-22 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 18:34:26 UTC, houdoux09 wrote: void Read(T)(T value) { foreach(i, mm; value.tupleof) { writeln(__traits(identifier, value.tupleof[i]), " = ", mm); if(isArray!(typeof(mm))) { Read(mm[0]); //Error } } } You need to us

Re: Recommend: IDE and GUI library

2017-02-27 Thread thedeemon via Digitalmars-d-learn
On Friday, 24 February 2017 at 22:44:55 UTC, XavierAP wrote: Hi I've looked at wiki.dlang.org/IDEs, and I see that Visual D is linked from dlang.org/download.html. Still I was looking for personal opinions and experiences beyond hard specs, I wonder if one of the IDEs is already dominant at lea

Re: Recommend: IDE and GUI library

2017-03-01 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 17:37:02 UTC, XavierAP wrote: I'm trying now DlangUI on Visual D. I'm getting different errors from missing Derelict library dependencies... If you're building your app with VisualD (as opposed to invoking dub externally), make sure you've set up import paths in p

Re: Recommend: IDE and GUI library

2017-03-01 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 23:44:47 UTC, XavierAP wrote: Still I want to be able to be able to work and debug from Visual Studio. The way I did on Windows: 1) get dlangui via dub 2) go to its folder in AppData\roaming\dub\packages and edit dub.json: * find "minimal" configuration * add

Re: scope(~this)

2017-03-13 Thread thedeemon via Digitalmars-d-learn
On Monday, 13 March 2017 at 14:28:01 UTC, Inquie wrote: On Monday, 13 March 2017 at 05:18:18 UTC, Nicholas Wilson wrote: On Sunday, 12 March 2017 at 21:38:44 UTC, Inquie wrote: Is there any easy way to create a scope for termination of the object? I have a template method that takes a type an

Re: scope(~this)

2017-03-15 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 14:35:11 UTC, Inquie wrote: There is really no any arrays to keep track of or anything like that matter you stated. ... 3 steps: ... 3. The compiler calls all the delegates on destruction. Here you are. "All the delegates" - where are they stored? This is the arra

Re: scope(~this)

2017-03-15 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 12:56:10 UTC, Inquie wrote: If it is trivial, can you write up a quick solution. I don't see how to accomplish it easily. Here it is, source and output: https://dpaste.dzfl.pl/bbf162529c6c

Re: Sorting Assosiative Arrays and Finding Largest Common Substring

2017-03-16 Thread thedeemon via Digitalmars-d-learn
On Thursday, 16 March 2017 at 16:02:13 UTC, helxi wrote: I was looking for ways to find the largest common substring between two given substrings and have learnt 1. .length is of type ulong Only when compiling to 64 bits. On 32-bit target it's different. 2. writing string[int] will not give

Re: List Comprehension equivalent

2017-03-18 Thread thedeemon via Digitalmars-d-learn
On Saturday, 18 March 2017 at 11:09:34 UTC, Russel Winder wrote: Is this foldr or foldl' ? It's a left fold of course, having foldr by default in eager language would be awkward.

Re: GC: Understanding potential sources of false pointers

2017-04-20 Thread thedeemon via Digitalmars-d-learn
On Thursday, 20 April 2017 at 02:27:37 UTC, Nick Sabalausky (Abscissa) wrote: According to : "Registers, the stack, and any other memory locations added through the GC.addRange function are always scanned conservatively." 1. Can that be safely assume

<    1   2