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

2022-12-04 Thread rempas via Digitalmars-d-learn
On Sunday, 4 December 2022 at 17:27:39 UTC, Nick Treleaven wrote: On Sunday, 4 December 2022 at 16:33:35 UTC, rempas wrote: (MemoryBlock.sizeof is 16 on my 64-bit system). The above adds 16 bytes to ptr. The above adds 16 * MemoryBlock.sizeof bytes (16 * 16) to ptr, because ptr is cast

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

2022-12-04 Thread rempas via Digitalmars-d-learn
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?

Re: Confused about something in the D book relating to precision

2022-12-04 Thread thebluepandabear via Digitalmars-d-learn
I have to agree. Nobody really knows these by heart. Once you know what's available, you just come back and pick what you need for that occasion. Ali Thanks for your effort :-) It helped clear things up.

Enum Default Initializer?

2022-12-04 Thread Salih Dincer via Digitalmars-d-learn
Hi All, are these results normal? The results have nothing to do with extern(c). I just wanted to see the simplest results. ```d extern (C) void main() { enum SAYI : char { bir = 49, iki } enum NUMS : SAYI { one = SAYI.bir, two = SAYI.iki } import core.stdc.stdio;

Re: Confused about something in the D book relating to precision

2022-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/4/22 18:57, thebluepandabear wrote: > I am not understanding why Ali said there is a decimal mark if precision > is nonzero? > > How can a number have zero precision? That "precision" is referring to how many digits are printed after the decimal mark in the formatted output. > "the

Confused about something in the D book relating to precision

2022-12-04 Thread thebluepandabear via Digitalmars-d-learn
Hello guys, (Noob question.) I would appreciate some help. I am reading Ali's book on D language, and I am up to page 127 -- talking about format specifiers. He says the following about the '%e' (exponent) specifier: "e: A floating point argument is printed according to the following

Re: raylib-d Gamepad Detection Fails

2022-12-04 Thread jwatson-CO-edu via Digitalmars-d-learn
On Friday, 2 December 2022 at 01:03:47 UTC, Steven Schveighoffer wrote: It's important to remember that raylib-d doesn't do any special things with the raylib functions -- they are just straight calls into the library. -Steve Indeed, I plugged a different gamepad into the same system

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Ali Çehreli via Digitalmars-d-learn
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 to 800 could continue because order of memory operations may

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
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 analysis. Consider for example, the GC scans address 0 - 1000 and

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread rikki cattermole via Digitalmars-d-learn
ALl it means is certain memory patterns (such as writes), will tell the GC about it. Its required for pretty much all advanced GC designs, as a result we are pretty much maxing out what we can do. Worth reading:

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/4/22 12:17, Adam D Ruppe wrote: On Sunday, 4 December 2022 at 17:53:00 UTC, Adam D Ruppe wrote: Interesting... you know, maybe D's GC should formally expose a mutex that you can synchronize on for when it is running. .. or compile in write barriers. then it doesn't matter if the

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 21:55:52 UTC, Siarhei Siamashka wrote: Do you mean the top of the https://code.dlang.org/?sort=score=library list? Well, I was referring to the five that appear on the homepage, which shows silly instead of emsi containers. How do you know that they embrace

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Siarhei Siamashka via Digitalmars-d-learn
On Sunday, 4 December 2022 at 12:37:08 UTC, Adam D Ruppe wrote: All of the top 5 most popular libraries on code.dlang.org embrace the GC. Do you mean the top of the https://code.dlang.org/?sort=score=library list? How do you know that they embrace GC? Is it possible to filter packages in

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 17:53:00 UTC, Adam D Ruppe wrote: Interesting... you know, maybe D's GC should formally expose a mutex that you can synchronize on for when it is running. .. or compile in write barriers. then it doesn't matter if the thread is unregistered, the write

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

2022-12-04 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 04, 2022 at 04:33:35PM +, rempas via Digitalmars-d-learn wrote: > First a little bit of theory. A pointer just points to a memory > address which is a number. So when I add "10" to this pointer, it will > point ten bytes after the place it was pointing to, right? This is true only

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 16:02:28 UTC, Ali Çehreli wrote: D's GC needed to stop the world, which meant it would have to know what threads were running. You can never be sure whether your D library function is being called from a thread you've known or whether the Java runtime (or other

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread ryuukk_ via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: Dear dlang community. I am unsure about what idiomatic D is. Some of the Dconf talks tells people just to use the GC, until you can't afford it. If there are documents that describes what idiomatic D is then I would appreciate it.

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

2022-12-04 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 4 December 2022 at 16:33:35 UTC, rempas wrote: struct MemoryBlock { char* ptr; ulong length; } (MemoryBlock.sizeof is 16 on my 64-bit system). void* ptr = cast(void*)0x7a7; void* right() { return cast(MemoryBlock*)(ptr + MemoryBlock.sizeof); // Cast the whole expression

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

2022-12-04 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 4 December 2022 at 16:33:35 UTC, rempas wrote: First a little bit of theory. A pointer just points to a memory address which is a number. So when I add "10" to this pointer, it will point ten bytes after the place it was pointing to, right? Not quite. Adding 10 to a T* means

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread vushu via Digitalmars-d-learn
On Sunday, 4 December 2022 at 15:57:26 UTC, Ali Çehreli wrote: On 12/4/22 05:58, vushu wrote: > I was worried if my library should be GC free May I humbly recommend you question where that thinking comes from? Ali P.S. I used to be certain that the idea of GC was wrong and the creators of

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

2022-12-04 Thread rempas via Digitalmars-d-learn
First a little bit of theory. A pointer just points to a memory address which is a number. So when I add "10" to this pointer, it will point ten bytes after the place it was pointing to, right? Another thing with pointers is that it doesn't have "types". A pointer always just points to a

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/4/22 06:27, Sergey wrote: > if it will be possible to write > library in D and use it from > C/++/Python/R/JVM(JNI)/Erlang(NIF)/nameYourChoice smoothly it will be a > win. Years ago we tried to call D from Java. I realized that it was very tricky to introduce the calling thread to D's

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Ali Çehreli via Digitalmars-d-learn
On 12/4/22 05:58, vushu wrote: > I was worried if my library should be GC free May I humbly recommend you question where that thinking comes from? Ali P.S. I used to be certain that the idea of GC was wrong and the creators of runtimes with GC were simpletons. In contrast, people like me,

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Sergey via Digitalmars-d-learn
On Sunday, 4 December 2022 at 12:37:08 UTC, Adam D Ruppe wrote: All of the top 5 most popular libraries on code.dlang.org embrace the GC. Interesting. It seems that most of the community suppose that “library” should be used from D :-) But in my opinion - “foreign library experience” is much

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread vushu via Digitalmars-d-learn
On Sunday, 4 December 2022 at 13:03:07 UTC, Hipreme wrote: On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: Dear dlang community. I am unsure about what idiomatic D is. Some of the Dconf talks tells people just to use the GC, until you can't afford it. If there are documents that

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread vushu via Digitalmars-d-learn
On Sunday, 4 December 2022 at 12:37:08 UTC, Adam D Ruppe wrote: On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: What are your thoughts about using GC as a library writer? Do it. It is lots of gain for very little loss. If you wan't to include a library into your project aren't you

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread bachmeier via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: Dear dlang community. I am unsure about what idiomatic D is. Idiomatic D code produces the correct result, it's readable, and it's easy for others to use. Some of the Dconf talks tells people just to use the GC, until you can't

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Hipreme via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: Dear dlang community. I am unsure about what idiomatic D is. Some of the Dconf talks tells people just to use the GC, until you can't afford it. If there are documents that describes what idiomatic D is then I would appreciate it.

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe 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? Do it. It is lots of gain for very little loss. If you wan't to include a library into your project aren't you more inclined to use a library which is gc free? No, GC free

Idiomatic D using GC as a library writer

2022-12-04 Thread vushu via Digitalmars-d-learn
Dear dlang community. I am unsure about what idiomatic D is. Some of the Dconf talks tells people just to use the GC, until you can't afford it. If there are documents that describes what idiomatic D is then I would appreciate it. So my questions are: What are your thoughts about

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

2022-12-04 Thread Salih Dincer via Digitalmars-d-learn
On Wednesday, 30 November 2022 at 03:04:47 UTC, Basile B. wrote: I have implemented that in [styx](https://gitlab.com/styx-lang/styx). 1. You have the type for dynamic arrays, called TypeRcArray, syntax is `Type[+]` 2. You have the type for slices (what you describe as a window), syntax