Re: How to compiler dlang code on Apple M1?

2022-12-17 Thread j via Digitalmars-d-learn
On Saturday, 3 December 2022 at 18:59:58 UTC, zoujiaqing wrote: ``` dub build --compiler=ldc2 --arch=arm64-apple-macos Starting Performing "debug" build using ldc2 for aarch64, arm_hardfloat. Building taggedalgebraic 0.11.22: building configuration [library] Building eventcore

Re: Is remove safe using foreach

2022-12-17 Thread j via Digitalmars-d-learn
On Monday, 12 December 2022 at 17:23:36 UTC, lili wrote: ``` int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4]; foreach (k ; aa.byKey) { if (k == "aaa") { aa.remove(k); aa["ww"] = 33; } if (k ==

Re: unique_ptr | Unique for autoclose handle

2022-12-17 Thread j via Digitalmars-d-learn
On Wednesday, 14 December 2022 at 11:30:07 UTC, Vitaliy Fadeev wrote: Hi! I open a device under Windows: ``` HANDLE h = CreateFileW( ... ); ``` in procedure: ``` HANDLE open_keyboard_device2( LPCWSTR path, int* error_number ) { ... HANDLE dev_handle = CreateFileW(

Re: _Symbols _with _leading _underscores

2022-12-17 Thread j via Digitalmars-d-learn
On Saturday, 17 December 2022 at 02:42:22 UTC, Paul wrote: I see code like this from time to time. Are the leading underscores significant, in general, in the D language? Is it just programmer preference? Is it a coding practice, in general, that is common...even outside of D? Thanks for

Re: How is this code invalid?

2022-12-17 Thread j via Digitalmars-d-learn
On Saturday, 17 December 2022 at 00:23:32 UTC, thebluepandabear wrote: I am reading the fantastic book about D by Ali Çehreli, and he gives the following example when he talks about variadic functions: ```D int[] numbersForLaterUse; void foo(int[] numbers...) { numbersForLaterUse =

Re: arsd.jni

2022-12-17 Thread jni via Digitalmars-d-learn
On Monday, 12 December 2022 at 15:03:13 UTC, Adam D Ruppe wrote: On Monday, 12 December 2022 at 11:17:47 UTC, jni wrote: It's good. But you did the java bindings by hand or is there a generator in arsd.jni for that too? It does it automatically. You compile jni.d with

Re: _Symbols _with _leading _underscores

2022-12-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 17 December 2022 at 02:42:22 UTC, Paul wrote: Are the leading underscores significant, in general, in the D language? The code you linked is a copy/paste from some C runtime library code, where the leading __ is the convention to indicate it is part of the private platform

Re: How is this code invalid?

2022-12-17 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 17, 2022 at 02:36:10AM +, thebluepandabear via Digitalmars-d-learn wrote: [...] > Thanks, I've tried to mark it with `@safe` and it did give me a > warning. > > I was also wondering, why is this code valid? > > ```D > int[] numbersForLaterUse; > > @safe void foo(int[] numbers)