Re: Member function forwarding

2022-02-18 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 17 February 2022 at 21:17:02 UTC, Andrey Zherikov wrote: On Thursday, 17 February 2022 at 20:59:43 UTC, Andrey Zherikov wrote: Another question: does `auto foo(ARGS...)(ARGS args) { return a.foo(args); }` correctly forward `ref`, `const` etc. arguments? Actually the answer is `NO

initializing struct containing user defined type

2022-02-18 Thread kdevel via Digitalmars-d-learn
Instead of using string I want to use A in the definition of B: struct A { string s; this (string s) { this.s = s; } } struct B { A a; A b; } Alas I have some difficulty initializing a B in the accustomed manner (b3): void main ()

Re: initializing struct containing user defined type

2022-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 2/18/22 06:19, kdevel wrote: > // auto b3 = B ("A", "B"); // Error: cannot implicitly convert > // expression `"A"` of type `string` to `A` Yeah, D disallows some implicit conversions. Adding a constructor to B will make it work: this(string as, string bs) { this.a = A(as);

Re: How to update Associative Array?

2022-02-18 Thread kdevel via Digitalmars-d-learn
On Monday, 14 February 2022 at 01:04:08 UTC, Ali Çehreli wrote: [...] Point taken but how deep should we understand library code, not all being Phobos. My pet peeve: import std.stdio; void main(string[] args) { writefln!"hello"(42); } /usr/include/dlang/dmd/std/stdio.d(4442): Error: no pr

Re: initializing struct containing user defined type

2022-02-18 Thread kdevel via Digitalmars-d-learn
On Friday, 18 February 2022 at 14:37:25 UTC, Ali Çehreli wrote: On 2/18/22 06:19, kdevel wrote: > // auto b3 = B ("A", "B"); // Error: cannot implicitly convert > // expression `"A"` of type `string` to `A` Yeah, D disallows some implicit conversions. Adding a constructor to B will m

Re: Does anyone build for Android? Tons of link errors..

2022-02-18 Thread Fry via Digitalmars-d-learn
I got it working, kind of. I just needed to use a different ndk version. There's a lot of problems with the NDK, the latest one doesn't appear to have the bfd linker anymore. Does anyone know why the bfd linker is needed and why the gold linker doesn't work for the emulated TLS?

Re: initializing struct containing user defined type

2022-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 2/18/22 07:01, kdevel wrote: > Error: struct `B` has constructors, cannot use `{ initializers }`, > use `B( initializers )` instead > > What is the rationale behind that? I mean: If the compiler exactly > sees what the program author intends to express why does it force the > author to

Re: Does anyone build for Android? Tons of link errors..

2022-02-18 Thread kinke via Digitalmars-d-learn
On Friday, 18 February 2022 at 16:28:56 UTC, Fry wrote: Does anyone know why the bfd linker is needed and why the gold linker doesn't work for the emulated TLS? It's required for LDC's custom TLS emulation for Android, see 1st point in https://wiki.dlang.org/Build_D_for_Android#Directions_for

Re: initializing struct containing user defined type

2022-02-18 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 18 February 2022 at 16:45:24 UTC, Ali Çehreli wrote: On 2/18/22 07:01, kdevel wrote: > Error: struct `B` has constructors, cannot use `{ initializers }`, > use `B( initializers )` instead > > What is the rationale behind that? I mean: If the compiler exactly > sees what the pr

Re: initializing struct containing user defined type

2022-02-18 Thread Ali Çehreli via Digitalmars-d-learn
On 2/18/22 12:16, Salih Dincer wrote: >// x.writeln(y); // 2.087 >"D Compiler v".writeln(__VERSION__/1000.0); > ``` > I'm using v2.087 but because of @disable this line doesn't work: ```// > x.writeln(y); // 2.087``` > > Why? Can you give an explanation for this? This is not related to s

Re: initializing struct containing user defined type

2022-02-18 Thread forkit via Digitalmars-d-learn
On Friday, 18 February 2022 at 16:45:24 UTC, Ali Çehreli wrote: ... I think that syntax will be obviated when D will have named arguments. Ali Huh? D doesn't have named arguments, already? That's an important component for safe(r) programming. Do you know if there is a DIP for this, and i

Re: initializing struct containing user defined type

2022-02-18 Thread user1234--- via Digitalmars-d-learn
On Friday, 18 February 2022 at 23:46:51 UTC, forkit wrote: On Friday, 18 February 2022 at 16:45:24 UTC, Ali Çehreli wrote: ... I think that syntax will be obviated when D will have named arguments. Ali Huh? D doesn't have named arguments, already? That's an important component for safe(r)