Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread rikki cattermole via Digitalmars-d-learn
On 30/08/2022 8:16 AM, Gavin Ray wrote: It must have been the "writing at end of file" bit? I don't know. It read like it should work. The offsets were correct, it just didn't work *shrug*.

Re: Code compiles and run fine with LDC but segfault with DMD

2022-08-29 Thread zjh via Digitalmars-d-learn
On Monday, 29 August 2022 at 21:46:48 UTC, ryuukk_ wrote: What `-g` does that makes this code compile and work with DMD? I guess it's global sharing. not `tls`.

Re: Code compiles and run fine with LDC but segfault with DMD

2022-08-29 Thread ryuukk_ via Digitalmars-d-learn
I forgot to add: this is on Windows, the problem doesn't exist with linux I reported a bug here: https://issues.dlang.org/show_bug.cgi?id=23310

Code compiles and run fine with LDC but segfault with DMD

2022-08-29 Thread ryuukk_ via Digitalmars-d-learn
The following code compiles and run fine with LDC, but with DMD it compiles and then default at runtime ```D -- app.d enum Test {A, B, C} Test test = Test.A; extern(C) void main() { switch(test) { default: break; } } ``` ``` -- object.d // empty for now ```

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread Gavin Ray via Digitalmars-d-learn
On Monday, 29 August 2022 at 15:52:31 UTC, rikki cattermole wrote: After a bunch of playing around I managed to determine that it is as simple as the mode. exists(dbFileName) ? "r+" : "w+" Will fix it. Of course you shouldn't delete the file like that method is doing. It should probably

Re: How to use a non-static objects in string `mixin`?

2022-08-29 Thread Dukc via Digitalmars-d-learn
On Saturday, 27 August 2022 at 13:20:13 UTC, hype_editor wrote: I need to use function `eval` sometimes, but compiler throws an error: `Error: variable `firstOperand` cannot be read at compile time`. You're probably misunderstanding `mixin`. It does not work like an eval function at Lisp or

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 29 August 2022 at 16:21:53 UTC, ag0aep6g wrote: You never change `pageId`. So as far as I can tell, you're always `seek`-ing to the same position, and you just overwrite the same piece of the file again and again. Whoops. I guess I missed the point of the question there.

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 28 August 2022 at 22:46:17 UTC, Gavin Ray wrote: I've put the code, stripped to a minimal example here: - https://ldc.godbolt.org/z/fzsx3Tnnn [...] But if the same code is placed inside of a `for` loop, suddenly no writes occur: [...] Does anyone know what is happening here?

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread rikki cattermole via Digitalmars-d-learn
After a bunch of playing around I managed to determine that it is as simple as the mode. exists(dbFileName) ? "r+" : "w+" Will fix it. Of course you shouldn't delete the file like that method is doing. It should probably reinitialize the FILE* descriptor.

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread Gavin Ray via Digitalmars-d-learn
On Monday, 29 August 2022 at 07:04:49 UTC, bauss wrote: Does anyone know what is happening here? It's really puzzling. You probably need to flush the output. That's a good idea. I gave it a shot, and the following doesn't seem to change anything unfortunately: ```d void writePage(PageId

Re: how to install the new dmd on Mac M1?

2022-08-29 Thread Guillaume Piolat via Digitalmars-d-learn
On Thursday, 25 August 2022 at 14:19:47 UTC, MichaelBi wrote: I downloaded the new dmd 2.1 on Mac, but with fail message of "unsupported Arch arm64". how can I do? thanks. ## Step 1 Get LDC here: https://github.com/ldc-developers/ldc/releases - If you are running on Apple Silicon, be sure

Re: Disk write in a "for" loop with RwMutex never happens

2022-08-29 Thread bauss via Digitalmars-d-learn
On Sunday, 28 August 2022 at 22:46:17 UTC, Gavin Ray wrote: I've put the code, stripped to a minimal example here: - https://ldc.godbolt.org/z/fzsx3Tnnn You can see that the single write + read version of the code works just fine: ``` pageData[0..4] = [1, 2, 3, 4] readData[0..4] = [1, 2, 3,