Re: Why is this allowed? Inheritance variable shadowing

2019-08-13 Thread a11e99z via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 06:39:24 UTC, a11e99z wrote: On Tuesday, 13 August 2019 at 05:57:23 UTC, Mike Parker wrote: On Tuesday, 13 August 2019 at 04:40:53 UTC, Chris Katko wrote: OT: and again how to easy to google info about error/warning just with one word "CS0108" D can use attrs f

Re: Local static class fields

2019-08-13 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 04:43:29 UTC, Paul Backus wrote: On Monday, 12 August 2019 at 22:48:43 UTC, Bert wrote: Making a field static is effectively a global variable to the class. I have a recursive class structure(think of a graph or tree) and I need to keep a global state for it, but

Re: Local static class fields

2019-08-13 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 12 August 2019 at 22:48:43 UTC, Bert wrote: Making a field static is effectively a global variable to the class. I have a recursive class structure(think of a graph or tree) and I need to keep a global state for it, but this state actually needs to be different for each tree object

How to use #pragma omp parallel for collapse(n) in dlang?

2019-08-13 Thread ijet via Digitalmars-d-learn
How to use #pragma omp parallel for collapse(n) in dlang?

Re: Local static class fields

2019-08-13 Thread Bert via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 04:43:29 UTC, Paul Backus wrote: On Monday, 12 August 2019 at 22:48:43 UTC, Bert wrote: Making a field static is effectively a global variable to the class. I have a recursive class structure(think of a graph or tree) and I need to keep a global state for it, but

Blog Post #0061: Cairo Toy Text

2019-08-13 Thread Ron Tarrant via Digitalmars-d-learn
When all you want is quick-n-dirty text in a GTK DrawingArea and Pango seems like more than you wanna deal with, Cairo's Toy Text will do the job nicely. Here's how: https://gtkdcoding.com/2019/08/13/0061-cairo-v-toy-text-image-formats.html

Re: What the abstrac final class mean?

2019-08-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-08-12 11:25, a11e99z wrote: its weird that next compiles in some weird form import std; static class A {     static a() { "a".writeln; } // forgot return type } Since you have specified an attribute on "a", the compiler can infer the return type. In this case it's inferred to "void"

Re: What the abstrac final class mean?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 13, 2019 3:03:49 AM MDT Jacob Carlborg via Digitalmars-d- learn wrote: > On 2019-08-12 11:25, a11e99z wrote: > > its weird that next compiles in some weird form > > > > import std; > > static class A { > > > > static a() { "a".writeln; } // forgot return type > > > > } > > S

Re: Desktop app with vibe.d

2019-08-13 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2019-08-12 at 20:01 +, DanielG via Digitalmars-d-learn wrote: > On Monday, 12 August 2019 at 10:41:57 UTC, GreatSam4sure wrote: > > I will be happy if I can build an app in D with fanciful ui. I > > will also be happy if you know any other way to build a > > fanciful ui in D like adob

Re: Is it possible to target all platforms that Qt Quick can target?

2019-08-13 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2019-08-12 at 17:45 +, Enjoys Math via Digitalmars-d-learn wrote: > Hi, > > I'm writing my GUI in C++ & Qt Quick. I know that I could > connect to D from the GUI code using a DLL, but can something > similar be done on the other PC OS's and the mobile OS's? > > Thanks. > Looking

How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
Hello there, If I had a DLL, how would I sort it judging by the node contents, the D way? In C if I were to sort a piece of malloc'd memory pointing to node pointers, I would write my compare function and let qsort sort it out. In D, I tried to use std.algorithm's sort functionality to no av

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk wrote: Hello there, If I had a DLL, how would I sort it judging by the node contents, the D way? [...] Node.t Node.x, my bad

Re: Desktop app with vibe.d

2019-08-13 Thread GreatSam4sure via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 09:44:59 UTC, Russel Winder wrote: On Mon, 2019-08-12 at 20:01 +, DanielG via Digitalmars-d-learn wrote: [...] GtkD allows for "reactive" UI. https://www.reactivemanifesto.org/ There is also Qt, I haven't tried any of the D bindings to Qt, but given Qt is

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Daniel Kozak via Digitalmars-d-learn
You can make an array from it On Tue, Aug 13, 2019 at 12:05 PM Mirjam Akkersdijk via Digitalmars-d-learn wrote: > > On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk > wrote: > > Hello there, > > If I had a DLL, how would I sort it judging by the node > > contents, the D way? > > > >

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 13, 2019 3:48:52 AM MDT Mirjam Akkersdijk via Digitalmars-d-learn wrote: > Hello there, > If I had a DLL, how would I sort it judging by the node contents, > the D way? > > In C if I were to sort a piece of malloc'd memory pointing to > node pointers, I would write my compare fu

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread ikod via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk wrote: Hello there, If I had a DLL, how would I sort it judging by the node contents, the D way? In C if I were to sort a piece of malloc'd memory pointing to node pointers, I would write my compare function and let qsort sort it

Re: Local static class fields

2019-08-13 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 08:41:02 UTC, Bert wrote: On Tuesday, 13 August 2019 at 04:43:29 UTC, Paul Backus wrote: It seems to me like the obvious solution is to use two different classes, one to store the global state, and one to store the individual objects in your structure. For example:

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk wrote: I would write my compare function and let qsort sort it out. I'm confused by this statement. Are you referring to the qsort in C's stdlib? I had never heard of using that to sort a linked list, so I searched, and it is not

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk wrote: and I would like to sort based on Node.t, how should I tackle it, preferably without resorting to C libraries? Convert the nodes into an D array, sort the array with nodes.sort!"a.x < b.x" and then iterate the array and repai

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 12:34:46 UTC, bachmeier wrote: I'm confused by this statement. Are you referring to the qsort in C's stdlib? I had never heard of using that to sort a linked list, so I searched, and it is not possible. Ah yes, maybe I should have elaborated. In C, you can just cr

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe wrote: On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk wrote: and I would like to sort based on Node.t, how should I tackle it, preferably without resorting to C libraries? Convert the nodes into an D array, sort the ar

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 13, 2019 11:33:10 AM MDT Mirjam Akkersdijk via Digitalmars-d-learn wrote: > On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe > > wrote: > > On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk > > > > wrote: > >> and I would like to sort based on Node.t, how

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Johannes Loher via Digitalmars-d-learn
Am 13.08.19 um 11:48 schrieb Mirjam Akkersdijk: > Hello there, > If I had a DLL, how would I sort it judging by the node contents, the D > way? > > In C if I were to sort a piece of malloc'd memory pointing to node > pointers, I would write my compare function and let qsort sort it out. > In D, I

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 12:12:28PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, August 13, 2019 11:33:10 AM MDT Mirjam Akkersdijk via > Digitalmars-d-learn wrote: [...] > > Thank you, this is what I eventually chose to do. It's also fairly > > fast, though doesn't the natu

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Ali Çehreli via Digitalmars-d-learn
On 08/13/2019 10:33 AM, Mirjam Akkersdijk wrote: > On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe wrote: >> Convert the nodes into an D array, sort the array with nodes.sort!"a.x >> < b.x" and then iterate the array and repair the next/prev pointers. If possible, I would go further

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 11:28:35AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > Summary: Ditch the linked list and put the elements into an array. :) [...] +1. The linked list may have been faster 20 years ago, before the advent of modern CPUs with caching hierarchies and memory acc

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 18:28:35 UTC, Ali Çehreli wrote: On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe > wrote: > Convert the nodes into an D array, sort the array with > nodes.sort!"a.x < b.x" and then iterate the array and repair > the next/prev pointers. If possible, I

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 18:54:58 UTC, H. S. Teoh wrote: On Tue, Aug 13, 2019 at 11:28:35AM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] Summary: Ditch the linked list and put the elements into an array. :) [...] +1. The linked list may have been faster 20 years ago, before t

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Aug 13, 2019 at 08:42:37PM +, Max Haughton via Digitalmars-d-learn wrote: > On Tuesday, 13 August 2019 at 18:54:58 UTC, H. S. Teoh wrote: [...] > > These days, with CPU multi-level caches and memory access > > predictors, in-place arrays are often the best option for > > performance, u

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 18:28:35 UTC, Ali Çehreli wrote: > can't I define an array of fixed size, which is dependent on the input > of the function? arr.length = number_of_elements; All elements will be initialized to the element's default value, which happens to be null for pointers

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mirjam Akkersdijk via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 21:11:41 UTC, H. S. Teoh wrote: A contiguous allocator doesn't help after the list has undergone a large number of insertions/deletions, because of fragmentation. Fragmentation should not be an issue, I insist on keep using a DLL for the base structure in my applic

Re: How should I sort a doubly linked list the D way?

2019-08-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 22:12:23 UTC, Mirjam Akkersdijk wrote: Though, it left me with some semi-offtopic questions unanswered: (1) Ali, do you mean that from an optimization viewpoint, it's better to keep appending like `nodes ~= ...` instead of setting the length first? I would like