Re: Why infinite loops are faster than finite loops?

2020-06-20 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 20 June 2020 at 21:11:57 UTC, tastyminerals wrote: I am not sure that this is a question about D or a more general one. I have watched this nice presentation "Speed Is Found In The Minds of People" by Andrei: https://www.youtube.com/watch?v=FJJTYQYB1JQ&feature=youtu.be?t=2596 and o

Why infinite loops are faster than finite loops?

2020-06-20 Thread tastyminerals via Digitalmars-d-learn
I am not sure that this is a question about D or a more general one. I have watched this nice presentation "Speed Is Found In The Minds of People" by Andrei: https://www.youtube.com/watch?v=FJJTYQYB1JQ&feature=youtu.be?t=2596 and on 43:20 he says that "push_heap" is slow because of structured lo

Re: are std.traits.FieldNameTuple and std.traits.Fields returned value always in sync?

2020-06-20 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 20 June 2020 at 20:17:54 UTC, mw wrote: Are their returned value, i.e the field names and their types are always in the same order, and of the same length? If they are not, how to get sync-ed pairs (name, type)? If they are, why we need two separate calls, which cause confusion.

are std.traits.FieldNameTuple and std.traits.Fields returned value always in sync?

2020-06-20 Thread mw via Digitalmars-d-learn
Are their returned value, i.e the field names and their types are always in the same order, and of the same length? If they are not, how to get sync-ed pairs (name, type)? If they are, why we need two separate calls, which cause confusion.

Re: How to work Get & Set text in clipboard in Windows ?

2020-06-20 Thread Vinod K Chandran via Digitalmars-d-learn
On Saturday, 20 June 2020 at 13:46:05 UTC, Dennis wrote: Thanks a lot. Well, i thought it should be a one liner like- Clipboard.SetText(sText) But after reading your reply, i realized that this is D, not a scripting language. :)

Re: why cannot spawn function defined in unittest block {}?

2020-06-20 Thread mw via Digitalmars-d-learn
On Saturday, 20 June 2020 at 18:08:06 UTC, mw wrote: On Saturday, 20 June 2020 at 18:01:51 UTC, Adam D. Ruppe wrote: On Saturday, 20 June 2020 at 17:43:42 UTC, mw wrote: the function defined in unittest become a delegate? how to work-around this? just add the keyword static to the functions

Re: why cannot spawn function defined in unittest block {}?

2020-06-20 Thread mw via Digitalmars-d-learn
On Saturday, 20 June 2020 at 18:01:51 UTC, Adam D. Ruppe wrote: On Saturday, 20 June 2020 at 17:43:42 UTC, mw wrote: the function defined in unittest become a delegate? how to work-around this? just add the keyword static to the functions https://github.com/mingwugmail/dlang_tour/blob/master

Re: why cannot spawn function defined in unittest block {}?

2020-06-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 20 June 2020 at 17:43:42 UTC, mw wrote: the function defined in unittest become a delegate? how to work-around this? just add the keyword static to the functions

why cannot spawn function defined in unittest block {}?

2020-06-20 Thread mw via Digitalmars-d-learn
put the code from: https://tour.dlang.org/tour/en/multithreading/synchronization-sharing in file, and put unittest block from safePrint() to main() as here: https://github.com/mingwugmail/dlang_tour/blob/master/spawn_in_unittest.d#L33 - $ dmd -unittest spawn_in_unittest.d spaw

Re: why cannot spawn function defined in unittest block {}?

2020-06-20 Thread mw via Digitalmars-d-learn
the function defined in unittest become a delegate? how to work-around this?

GtkD code review - How to update a progressbar using data sharing concurrency

2020-06-20 Thread adnan338 via Digitalmars-d-learn
Hello, I need a code review on my strategy of updating a GtkD progressbar. Gtk is not thread safe, I interpret that as "I must only access data available in the main thread from the Gtk objects". This example is a simplified excerpt of my project. I have never done concurrency before and thus

Re: How to work Get & Set text in clipboard in Windows ?

2020-06-20 Thread Dennis via Digitalmars-d-learn
On Saturday, 20 June 2020 at 13:32:22 UTC, Vinod K Chandran wrote: I would like to know how to get & set text in clipboard. I am using windows machine. This is an example of setting the clipboard using the Windows API in D: ``` /// Returns: true on success bool setClipboard(string str) {

How to work Get & Set text in clipboard in Windows ?

2020-06-20 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I would like to know how to get & set text in clipboard. I am using windows machine. Thanks in advance. --Vinod Chandran

Re: Reading text (I mean "real" text...)

2020-06-20 Thread Denis via Digitalmars-d-learn
Digging into this a bit further -- POSIX defines a "print" class, which I believe is an exact fit. The Unicode spec doesn't define this class, which I presume is why D's std.uni library also omits it. But there is an isprint() function in libc, which I should be able to use (POSIX here). This