Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread bauss via Digitalmars-d-learn
On Monday, 5 December 2022 at 06:12:44 UTC, rempas wrote: On Sunday, 4 December 2022 at 16:40:17 UTC, ag0aep6g wrote: Not quite. Adding 10 to a T* means adding 10 * T.sizeof. Oh! I thought it was addition. Is there a specific reasoning for that if you are aware of? Because it's much easier

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 4 December 2022 at 23:37:39 UTC, Ali Çehreli wrote: On 12/4/22 15:25, Adam D Ruppe wrote: > which would trigger the write barrier. The thread isn't > allowed to complete this operation until the GC is done. According to my limited understanding of write barriers, the thread moving t

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread Guillaume Piolat via Digitalmars-d-learn
There are legitimate uses cases when you can't afford the runtime machinery (attach/detach every incoming thread in a shared library), more than not being able to afford the GC from a performance point of view. GC gives you higher productivity and better performance with the time gained. No

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread Guillaume Piolat via Digitalmars-d-learn
On Sunday, 4 December 2022 at 21:55:52 UTC, Siarhei Siamashka wrote: Is it possible to filter packages in this list by @nogc or @safe compatibility? You can list DUB packages for "@nogc usage" https://code.dlang.org/?sort=score&limit=20&category=library.nogc

LSP-server for D?

2022-12-05 Thread Per Nordlöw via Digitalmars-d-learn
Is there a D lsp-server available? I couldn't find anything at https://code.dlang.org/search?q=lsp. Am I not using the correct search terms?

Re: LSP-server for D?

2022-12-05 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 5 December 2022 at 12:23:24 UTC, Per Nordlöw wrote: Is there a D lsp-server available? I couldn't find anything at https://code.dlang.org/search?q=lsp. Am I not using the correct search terms? Ahh, it's at https://code.dlang.org/packages/serve-d.

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread rempas via Digitalmars-d-learn
On Sunday, 4 December 2022 at 19:00:15 UTC, H. S. Teoh wrote: This is true only if you're talking about pointers in the sense of pointers in assembly language. Languages like C and D add another layer of abstraction over this. Another thing with pointers is that it doesn't have "types". T

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread cc via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: What are your thoughts about using GC as a library writer? If your program runs, does some stuff, and terminates, use the GC. If your program runs, stays up for a while with user occasionally interacting with it, use the GC. If your prog

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread rempas via Digitalmars-d-learn
On Monday, 5 December 2022 at 08:21:44 UTC, bauss wrote: Because it's much easier to work with. Ex. if you have an array of 4 signed 32 bit integers that you're pointing to then you can simply just increment the pointer by 1. If it was raw bytes then you'd have to increment the pointer by

Variation in prefix sum

2022-12-05 Thread Soham Mukherjee via Digitalmars-d-learn
I'm attempting to parallelize some program that solves recursive linear equations. Some of these, I believe, might be modified into prefix sums. Here are a handful of examples of the equations I'm dealing with. The conventional prefix sum is as follows: ``` y[i] = y[i-1] + x[i] ``` One equation

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread jmh530 via Digitalmars-d-learn
On Sunday, 4 December 2022 at 23:25:34 UTC, Adam D Ruppe wrote: On Sunday, 4 December 2022 at 22:46:52 UTC, Ali Çehreli wrote: That's way beyond my pay grade. Explain please. :) The reason that the GC stops threads right now is to ensure that something doesn't change in the middle of its anal

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread vushu via Digitalmars-d-learn
On Monday, 5 December 2022 at 10:48:59 UTC, Guillaume Piolat wrote: There are legitimate uses cases when you can't afford the runtime machinery (attach/detach every incoming thread in a shared library), more than not being able to afford the GC from a performance point of view. [...] Thanks

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread vushu via Digitalmars-d-learn
On Monday, 5 December 2022 at 10:53:33 UTC, Guillaume Piolat wrote: On Sunday, 4 December 2022 at 21:55:52 UTC, Siarhei Siamashka wrote: Is it possible to filter packages in this list by @nogc or @safe compatibility? You can list DUB packages for "@nogc usage" https://code.dlang.org/?sort=scor

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread vushu via Digitalmars-d-learn
On Sunday, 4 December 2022 at 17:47:38 UTC, ryuukk_ wrote: On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: [...] D gives you the choice But the most important thing is your usecase, what kind of library are you making? Once you answer this question, you can then ask what your me

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 5 December 2022 at 15:08:41 UTC, rempas wrote: Got it! I guess they could also just allow us to use bracket notation to do the same thing. So something like: ```d foreach (i; 0 .. list.length) { (cast(int*)ptr[i]) = i; } ``` This is what happens with arrays anyways. And arrays ARE

Re: LSP-server for D?

2022-12-05 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 5 December 2022 at 12:38:07 UTC, Per Nordlöw wrote: On Monday, 5 December 2022 at 12:23:24 UTC, Per Nordlöw wrote: Is there a D lsp-server available? I couldn't find anything at https://code.dlang.org/search?q=lsp. Am I not using the correct search terms? Ahh, it's at https://code.

Re: Thinking about the difference between fixed and 'dynamic' arrays.

2022-12-05 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:54:53 UTC, Salih Dincer wrote: Recently DIP1044 was published about enum and although we can use `with()` instead we waste time unnecessarily... With cannot be used in calls. Hence when calling a function you need to either spell out the enum type or wrap the c

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread Salih Dincer via Digitalmars-d-learn
On Monday, 5 December 2022 at 18:01:47 UTC, ag0aep6g wrote: You can use bracket notation with pointers. You just need to move your closing parenthesis a bit. Assuming that `ptr` is a `void*`, these are all equivalent... Yeah, there is such a thing! I'm sure you'll all like this example: `

Re: LSP-server for D?

2022-12-05 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 5 December 2022 at 18:36:08 UTC, Per Nordlöw wrote: On Monday, 5 December 2022 at 12:38:07 UTC, Per Nordlöw wrote: On Monday, 5 December 2022 at 12:23:24 UTC, Per Nordlöw wrote: Is there a D lsp-server available? I couldn't find anything at https://code.dlang.org/search?q=lsp. Am I n

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread vushu via Digitalmars-d-learn
On Monday, 5 December 2022 at 14:48:33 UTC, cc wrote: On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: [...] If your program runs, does some stuff, and terminates, use the GC. If your program runs, stays up for a while with user occasionally interacting with it, use the GC. If your p

Re: How ptr arithmitic works??? It doesn't make any sense....

2022-12-05 Thread rempas via Digitalmars-d-learn
On Monday, 5 December 2022 at 18:01:47 UTC, ag0aep6g wrote: You can use bracket notation with pointers. You just need to move your closing parenthesis a bit. Assuming that `ptr` is a `void*`, these are all equivalent: ```d (cast(int*) ptr)[i] = whatever; *((cast(int*) ptr) + i) = whatever; *