Re: best memory profiler (to debug accumulated allocation of each line) for D?

2022-10-14 Thread mw via Digitalmars-d-learn
On Friday, 14 October 2022 at 19:06:12 UTC, rassoc wrote: On 10/14/22 20:45, mw via Digitalmars-d-learn wrote: Any suggestions? There's `dmd -profile=gc` or `dub build --build=profile-gc`. Thanks. I eventually use valgrind --tool=massif, and found the problem was in a underlying C library d

Re: Generate a pointer to a method of a struct

2022-10-14 Thread kdevel via Digitalmars-d-learn
On Saturday, 15 October 2022 at 00:31:47 UTC, Iain Buclaw wrote: ``` auto funcptr (alias method) () { return &method; } : fun = funcptr!bar; : ``` Which works but neither dmd nor gdc were able to optimize the additional function call away. pragma(inline, true) auto funcpt

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 22:17:52 UTC, H. S. Teoh wrote: Given that this particular trap crops up regularly, perhaps some sort of warning ought to be added. Once the @nodiscard DIP is accepted & implemented this should be easy to do. Seems like you're behind the times! The DIP was acce

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread Mike Parker via Digitalmars-d-learn
On Friday, 14 October 2022 at 21:51:54 UTC, WhatMeWorry wrote: I lost about a half an hour troubleshooting some code of mine which as it turned out to be resolved with just one line. // paths.remove(i); // compiles fine but does nothing paths = paths.remove(i); // works - what I erroneou

Re: Generate a pointer to a method of a struct

2022-10-14 Thread Iain Buclaw via Digitalmars-d-learn
On Friday, 14 October 2022 at 18:34:58 UTC, kdevel wrote: dmd and gdc optimize the lambda invocations away. Nonetheless the expression looks somewhat too big. To overcome this I tried to generate the function pointer outside of the struct: ``` auto funcptr (alias method) () { return &method

Re: Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Oct 14, 2022 at 09:51:54PM +, WhatMeWorry via Digitalmars-d-learn wrote: > > I lost about a half an hour troubleshooting some code of mine which as it > turned out to be resolved with just one line. > > > // paths.remove(i); // compiles fine but does nothing > > paths = paths.rem

Can someone tell me what the compiler thought I was trying to do?

2022-10-14 Thread WhatMeWorry via Digitalmars-d-learn
I lost about a half an hour troubleshooting some code of mine which as it turned out to be resolved with just one line. // paths.remove(i); // compiles fine but does nothing paths = paths.remove(i); // works - what I erroneously thought the previous line was doing Is the first line no

Re: library to solve the system of linear equations

2022-10-14 Thread Yura via Digitalmars-d-learn
On Friday, 14 October 2022 at 18:37:00 UTC, Sergey wrote: On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote: Dear All, I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler. At the moment I need to solve t

Re: best memory profiler (to debug accumulated allocation of each line) for D?

2022-10-14 Thread rassoc via Digitalmars-d-learn
On 10/14/22 20:45, mw via Digitalmars-d-learn wrote: Any suggestions? There's `dmd -profile=gc` or `dub build --build=profile-gc`.

best memory profiler (to debug accumulated allocation of each line) for D?

2022-10-14 Thread mw via Digitalmars-d-learn
Hi, With CPU profiler, we can see the accumulated run time of each function & line, I'm wondering if there is such a profiler for memory allocation? The reason I'm asking is because I suspect there are some small but repetitive memory allocation going on in the libraries (in C and D) I'm us

Re: library to solve the system of linear equations

2022-10-14 Thread Sergey via Digitalmars-d-learn
On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote: Dear All, I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler. At the moment I need to solve the system of liner equations: A00*q0 + A01*q1 + A02*q2 ...

Generate a pointer to a method of a struct

2022-10-14 Thread kdevel via Digitalmars-d-learn
Given a struct `S` with method `foo`: Any of these expressions ``` &foo &S.foo &.S.foo ``` when they occur inside the struct they represent a delegate and not a function pointer. Is it okay to "extract" and use the function pointer from the delegate in this way: ``` struct S { void

Re: library to solve the system of linear equations

2022-10-14 Thread M.M. via Digitalmars-d-learn
On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote: Dear All, I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler. [...] Did not try it, but the example for the function luSolve at the lubeck documentat

Re: library to solve the system of linear equations

2022-10-14 Thread Ben Jones via Digitalmars-d-learn
On Friday, 14 October 2022 at 17:41:42 UTC, Yura wrote: ... Check out MIR https://github.com/libmir

library to solve the system of linear equations

2022-10-14 Thread Yura via Digitalmars-d-learn
Dear All, I am very new to D, and it has been a while since I coded in anything than Python. I am using just notepad along with the gdc compiler. At the moment I need to solve the system of liner equations: A00*q0 + A01*q1 + A02*q2 ... = -V0 A10*q0 + A11*q1 + A12*q2 ... = -V1 ... I have all

Re: Float rounding (in JSON)

2022-10-14 Thread bauss via Digitalmars-d-learn
On Friday, 14 October 2022 at 09:00:11 UTC, Patrick Schluter wrote: On Thursday, 13 October 2022 at 19:27:22 UTC, Steven Schveighoffer wrote: On 10/13/22 3:00 PM, Sergey wrote: [...] It doesn't look really that far off. You can't expect floating point parsing to be exact, as floating point d

Re: Float rounding (in JSON)

2022-10-14 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 13 October 2022 at 19:27:22 UTC, Steven Schveighoffer wrote: On 10/13/22 3:00 PM, Sergey wrote: [...] It doesn't look really that far off. You can't expect floating point parsing to be exact, as floating point does not perfectly represent decimal numbers, especially when you get