Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Imperatorn via Digitalmars-d-learn
On Monday, 18 October 2021 at 04:11:18 UTC, Paul Backus wrote: On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote: My guess is that you got into this situation by trying to follow the example in the spec's section on ["Slice Assignment Operator Overloading"][2]. Unfortunately, that

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Paul Backus via Digitalmars-d-learn
On Monday, 18 October 2021 at 03:42:35 UTC, Paul Backus wrote: My guess is that you got into this situation by trying to follow the example in the spec's section on ["Slice Assignment Operator Overloading"][2]. Unfortunately, that example is incorrect. [2]:

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 17 October 2021 at 22:52:27 UTC, Elmar wrote: Hello Dear community. I'd like to overload `opIndexAssign` for a struct which wraps around a generic array (so that it can't support `opIndex` due to unknown return type). Broken down as much as possible this is the code: ``` import

Re: How to do a function pointer to "malloc" and "free"?

2021-10-17 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 17 October 2021 at 23:07:15 UTC, Elmar wrote: Do you have a link for more information how to initialize the D runtime? Export a function that calls this: http://druntime.dpldocs.info/core.runtime.Runtime.initialize.html And also export a function that calls this:

Re: How to do a function pointer to "malloc" and "free"?

2021-10-17 Thread Elmar via Digitalmars-d-learn
On Sunday, 10 October 2021 at 17:14:30 UTC, Adam Ruppe wrote: On Sunday, 10 October 2021 at 13:52:57 UTC, Elmar wrote: The language subset "BetterC" is required for calling D functions from C though. This is false. You can use any D features when calling it from C, you just need to provide

Re: Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Elmar via Digitalmars-d-learn
Btw, I should have written: `s.opIndexAssign(arr[1..4], s.opSlice(0,3));` But it compiles the same way.

Why is opIndexAssign replaced by opSlice here?

2021-10-17 Thread Elmar via Digitalmars-d-learn
Hello Dear community. I'd like to overload `opIndexAssign` for a struct which wraps around a generic array (so that it can't support `opIndex` due to unknown return type). Broken down as much as possible this is the code: ``` import std.stdio : writeln; import std.range : ElementType;

How can we allow using phobos with asserts/contracts?

2021-10-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/16/21 6:47 PM, solidstate1991 wrote: When I make this call ``` format(" %3.3f"w, avgFPS); ``` my program immediately crashes with an access violation error. The debugger out is different between x86 and x86-64. I've made all sanity checks, so I need some other suggestions. FYI,

Re: std.format doesn't want to work

2021-10-17 Thread solidstate1991 via Digitalmars-d-learn
On Sunday, 17 October 2021 at 13:03:46 UTC, jfondren wrote: then it's likely that some memory corruption prior to format() has broken the GC, and format's allocation of a string is what's failing. Try sprinkling `@safe` and and see what it complains about; try valgrind; try reducing your

Re: std.format doesn't want to work

2021-10-17 Thread jfondren via Digitalmars-d-learn
On Sunday, 17 October 2021 at 12:53:07 UTC, solidstate1991 wrote: On Sunday, 17 October 2021 at 05:22:17 UTC, russhy wrote: On Saturday, 16 October 2021 at 22:47:09 UTC, solidstate1991 wrote: When I make this call ``` format(" %3.3f"w, avgFPS); ``` my program immediately crashes with an access

Re: std.format doesn't want to work

2021-10-17 Thread solidstate1991 via Digitalmars-d-learn
On Sunday, 17 October 2021 at 05:22:17 UTC, russhy wrote: On Saturday, 16 October 2021 at 22:47:09 UTC, solidstate1991 wrote: When I make this call ``` format(" %3.3f"w, avgFPS); ``` my program immediately crashes with an access violation error. The debugger out is different between x86 and

Re: Can we use "ImportC" used yet?

2021-10-17 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 17 October 2021 at 10:46:30 UTC, data pulverizer wrote: Okay wow, this is amazing, I can now call R's standalone math library `Rmath.h` by converting: [...] Yeah it's pretty nice hey ☀️ But will become even more convenient later

Re: Can we use "ImportC" used yet?

2021-10-17 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 17 October 2021 at 10:46:30 UTC, data pulverizer wrote: Okay wow, this is amazing, I can now call R's standalone math library `Rmath.h` by converting ... Sorry you don't need `-lRmath` so the initial call should be: ``` gcc -E -P -I"/usr/share/R/include" r2d_con.c > r2d.c ```

Re: Can we use "ImportC" used yet?

2021-10-17 Thread data pulverizer via Digitalmars-d-learn
Okay wow, this is amazing, I can now call R's standalone math library `Rmath.h` by converting: ``` //r2d_con.c #define __restrict restrict #define __asm__ asm #define __extension__ #define __inline #define __builtin_bswap16 #define __builtin_bswap32 #define __builtin_bswap64 #define