Re: How can I make this work?

2021-03-16 Thread Jack via Digitalmars-d-learn
On Sunday, 28 February 2021 at 13:15:47 UTC, Adam D. Ruppe wrote: On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote: I'm using a windows callback function where the user-defined value is passed thought a LPARAM argument type. I'd like to pass my D array then access it from that callback

Re: D in AI Field

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 03:33:55 UTC, Lasheen wrote: Hello, I'm a C programmer, and now i want to migrate to D. i work in AI field, so i have some questions about D language: 1- is D suitable for mission critical systems(such as avionics systems) ? if (true){ 2- what about safety,

Re: Can't call splitter with range struct

2021-03-16 Thread drug via Digitalmars-d-learn
On 3/16/21 1:58 AM, David Skluzacek wrote: > > Error: template std.algorithm.iteration.splitter cannot deduce function from argument types !()(GZippedFile, string), candidates are: > /usr/include/dlang/dmd/std/algorithm/iteration.d(4678): splitter(alias pred = "a == b", Range, Separator)(Range

Make foreach element optional

2021-03-16 Thread Per Nordlöw via Digitalmars-d-learn
I find myself writing foreach (_; 0 .. n) doSomething(); // no using the variable `_` . What about relaxing the syntax to allow foreach (; 0 .. n) and/or foreach (0 .. n) ? Thereby making the `ForeachTypeList` of `AggregateForeach` in the grammar rule [1] optional. [1]

Re: Make foreach element optional

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 12:49:13 UTC, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n) doSomething(); // no using the variable `_` . What about relaxing the syntax to allow foreach (; 0 .. n) and/or foreach (0 .. n) ? Thereby making the `ForeachTypeList` of

Re: Make foreach element optional

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 13:52:29 UTC, Per Nordlöw wrote: On Tuesday, 16 March 2021 at 13:31:34 UTC, Imperatorn wrote: foreach(0..n) could work. Why though. When performing a side-effect n times. Then why not just do: auto times(alias F, T)(T number) {    return number.iota.each!(_ =>

Re: How can I make this work?

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 28 February 2021 at 13:15:47 UTC, Adam D. Ruppe wrote: And it is the simplest thing, no missing length, no weird property casting. The GC handled with two simple add/remove calls. Perfect example of teaching something. Thank you for this knowledge. Even though, this was not my

Re: How to open a compressed file in gz format ?

2021-03-16 Thread frame via Digitalmars-d-learn
On Monday, 15 March 2021 at 01:36:08 UTC, sharkloc wrote: I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. You can use the internal zlib instead of a shell. This example is using

Re: How can I make this work?

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 16:02:14 UTC, Vinod K Chandran wrote: On Sunday, 28 February 2021 at 13:15:47 UTC, Adam D. Ruppe wrote: And it is the simplest thing, no missing length, no weird property casting. The GC handled with two simple add/remove calls. Perfect example of teaching

Re: Make foreach element optional

2021-03-16 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 13:31:34 UTC, Imperatorn wrote: foreach(0..n) could work. Why though. When performing a side-effect n times.

Re: Make foreach element optional

2021-03-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/16/21 8:49 AM, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n)     doSomething(); // no using the variable `_` . What about relaxing the syntax to allow     foreach (; 0 .. n) and/or     foreach (0 .. n) ? Thereby making the `ForeachTypeList` of `AggregateForeach` in

Re: Make foreach element optional

2021-03-16 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 12:49:13 UTC, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n) doSomething(); // no using the variable `_` . What about relaxing the syntax to allow foreach (; 0 .. n) and/or foreach (0 .. n) ? Thereby making the `ForeachTypeList` of

Re: Make foreach element optional

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 15:02:54 UTC, Steven Schveighoffer wrote: On 3/16/21 8:49 AM, Per Nordlöw wrote: I find myself writing foreach (_; 0 .. n)     doSomething(); // no using the variable `_` . What about relaxing the syntax to allow     foreach (; 0 .. n) and/or     foreach (0

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 18:35:00 UTC, Imperatorn wrote: I see  Do you get CLR_INVALID in return? As far as i know this is the value of CLR_INVALID - 4294967295. And these are the results i got from my function. Set Text color result - 0 Set Text color result - 36962150 Set Text

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 18:35:00 UTC, Imperatorn wrote: I see  Do you get CLR_INVALID in return? From that results, second one contains my color value. Set Text color result - 0233FF66 RGB(102, 255, 51) is the color. 66 = 102 FF = 255 33 = 51

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 18:35:00 UTC, Imperatorn wrote: I see  Do you get CLR_INVALID in return? That results might be wrong. So i printed them in hex. These are the hex results. Set Text color result - Set Text color result - 0233FF66 Set Text color result - Set

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 19:15:02 UTC, Vinod K Chandran wrote: On Tuesday, 16 March 2021 at 18:35:00 UTC, Imperatorn wrote: I see  Do you get CLR_INVALID in return? That results might be wrong. So i printed them in hex. These are the hex results. Set Text color result - Set

Re: How to open a compressed file in gz format ?

2021-03-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/14/21 9:36 PM, sharkloc wrote: I want to read the content(file.gz) line by line,the following code is not friendly to large files of hundreds of Gb, and the memory overhead is also very large. import std.stdio; import std.process; import std.string; void main(string[] args){

Re: Can't call splitter with range struct

2021-03-16 Thread David Skluzacek via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 07:43:18 UTC, drug wrote: That means that you GZippedRange should provide opSlice operator and should be a narrow string (string of char or wchar) Yes, I should have looked more carefully at the doc, I was assuming splitter would accept a simple input range, but

rdmd and D equivalent for PYTHONPATH?

2021-03-16 Thread Chris Piker via Digitalmars-d-learn
Hi D I've writing little test scripts using rdmd to understand what various functions are really doing (ex: .take(5)). I'm up to the point where I need to write sample code to understand mir-algorithm a little better, but of course the library is not installed on my system. So two related

Re: rdmd and D equivalent for PYTHONPATH?

2021-03-16 Thread Chris Piker via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 03:43:22 UTC, Chris Piker wrote: Note: I'm aware of dub. This isn't a question about dub. I'm making scripts for local use, not redistributable binaries, so I would like to "install" mir-algorithm and similar libraries for my rdmd scripts to use. Sorry to

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 18:27:54 UTC, Vinod K Chandran wrote: On Tuesday, 16 March 2021 at 17:45:09 UTC, Imperatorn wrote: Omg the pain. Are you forced to use raw win api for this? Not at all. It's my hobby project. I choose raw win api. It's a fun. I see  Do you get CLR_INVALID

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Jack via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 17:26:01 UTC, Vinod K Chandran wrote: Hi all, I am creating a Button class with Win32 API functions. So far so good. I am using NM_CUSTOMDRAW message to change the back color of my buttons. It's really easy to change the back color in this way. But I can't change

Re: Make foreach element optional

2021-03-16 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 16:29:45 UTC, Imperatorn wrote: On Tuesday, 16 March 2021 at 13:52:29 UTC, Per Nordlöw wrote: On Tuesday, 16 March 2021 at 13:31:34 UTC, Imperatorn wrote: foreach(0..n) could work. Why though. When performing a side-effect n times. Then why not just do: auto

How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I am creating a Button class with Win32 API functions. So far so good. I am using NM_CUSTOMDRAW message to change the back color of my buttons. It's really easy to change the back color in this way. But I can't change the text color of my button. This is my pseudo code. ``` uint

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 17:26:01 UTC, Vinod K Chandran wrote: Hi all, I am creating a Button class with Win32 API functions. So far so good. I am using NM_CUSTOMDRAW message to change the back color of my buttons. It's really easy to change the back color in this way. But I can't change

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 17:45:09 UTC, Imperatorn wrote: Omg the pain. Are you forced to use raw win api for this? Not at all. It's my hobby project. I choose raw win api. It's a fun.

Re: Why are enums with base type string not considered strings?

2021-03-16 Thread wolframw via Digitalmars-d-learn
On Sunday, 14 March 2021 at 16:30:47 UTC, Bastiaan Veelo wrote: On Sunday, 14 March 2021 at 16:09:39 UTC, Imperatorn wrote: On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote: [...] May be a regression? https://issues.dlang.org/show_bug.cgi?id=16573 Indeed:

Re: How to change button text color in NM_CUSTOMDRAW (Win32 API question)

2021-03-16 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 19:42:26 UTC, Imperatorn wrote: At last, i found the answer myself. There is a item called dwDrawStage in NMCUSTOMDRAW structure. If value of dwDrawStage is equal to CDDS_PREERASE, call SetBkMode with transparent and call SetTextColor. Then draw text with

Re: How to delete dynamic array ?

2021-03-16 Thread mw via Digitalmars-d-learn
On Monday, 30 December 2013 at 08:13:30 UTC, bearophile wrote: How to free memory to the system immediately? What is your use case? The use case is: we want deterministic memory management, (and the application data is too big to fit into memory at once, so have to be processed batch by

Re: How to delete dynamic array ?

2021-03-16 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 16, 2021 at 11:28:00PM +, mw via Digitalmars-d-learn wrote: [...] > suppose: > > double[] data; // D type: dynamic array > > As of 2021 what's the correct way to allocate and deallocate (free > memory to the system immediately) D's dynamic array? [...] Note that T[] is just a