Member field of type nested struct must be initialized in constructor: Why?

2023-10-22 Thread Inkrementator via Digitalmars-d-learn
Consider this almost minimal example: ``` import std.algorithm; import std.range; import std.stdio; struct S(Nested){ Nested member; // = I.init; // Uncommenting this wouldn't help int g; this(Nested member){ this.member = member; }

Re: Member field of type nested struct must be initialized in constructor: Why?

2023-10-22 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 22 October 2023 at 21:02:32 UTC, Inkrementator wrote: Running the code with `rdmd -version=fix app.d` works, but running `rdmd -version=fix app.d` produces: `Error: field `member` must be initialized in constructor, because it is nested struct` Sorry, obviously it should be:

Re: Member field of type nested struct must be initialized in constructor: Why?

2023-10-23 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 22 October 2023 at 23:49:40 UTC, Paul Backus wrote: Nested structs contain a context pointer that needs to be initialized at runtime. If you don't initialize them, the pointer gets set to `null`, and the struct will not be able to access its context. I see, thanks for the

Re: DMD: How to compile executable without producing .obj file?

2023-11-09 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 5 November 2023 at 18:58:48 UTC, BoQsc wrote: When you compile using `dmd` compiler you will often get `.exe` and `.obj` file. I would like to only produce `.exe` file: On linux, gdc automatically cleans up object files by default. Passing it the -pipe option will prevent their

Re: Step by step tutorials for using bindings in D

2023-03-26 Thread Inkrementator via Digitalmars-d-learn
On Friday, 24 March 2023 at 23:45:15 UTC, eXodiquas wrote: Hello everyone, once again, I am here for your help. My last questions were answered really competently so I try again. :P So, maybe this is a stupid question, but I have read a lot about Bindings to C and C++ libraries for D. For

Re: Step by step tutorials for using bindings in D

2023-03-26 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 26 March 2023 at 18:49:57 UTC, eXodiquas wrote: On Sunday, 26 March 2023 at 14:09:19 UTC, Inkrementator wrote: But you said static bindings are the main portion of bindings we use. So I tried to get static Lua bindings going. Static Binding != Static Linking. Like I said, the

Re: Step by step tutorials for using bindings in D

2023-03-30 Thread Inkrementator via Digitalmars-d-learn
On Monday, 27 March 2023 at 00:45:28 UTC, Salih Dincer wrote: Likes **17** Views **265** Released on March **8, 2023** I'm surprised that you can get 300 views in a month on a primarily D video, but it's nice to see

Re: Proper way to handle "alias this" deprecation for classes

2023-05-10 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 7 May 2023 at 21:12:22 UTC, Chris Piker wrote: On the other hand, your first suggestion of using opCast() does seem like a reasonable choice to me. Can you provide a short code snippet using opCast to achieve the same result? I've never used it, and particularly I know that I

Re: Proper way to handle "alias this" deprecation for classes

2023-05-07 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 7 May 2023 at 18:19:04 UTC, Ali Çehreli wrote: alias this is for implicit type conversions, which can be achieved explicitly as well. Open question to everybody: What you're opinion on using opCast for this? Since it's a type conversion, it seems fitting to me. And another

Re: Function Composition

2024-01-29 Thread Inkrementator via Digitalmars-d-learn
On Thursday, 25 January 2024 at 18:44:26 UTC, atzensepp wrote: However this works: ```d int delegate (int) td = (x) => compose!(f,g,g,f,g,g,f,g,g,f)(x); ``` While not a real function pointer, this might already fit your needs. ```d alias td = compose!(f,g); ```

Re: Recommendation about templating engine library

2024-03-14 Thread Inkrementator via Digitalmars-d-learn
On Monday, 11 March 2024 at 16:10:24 UTC, Andrea wrote: just trying it out and kinda fits my needs; the main issues are lack of documentation and the need to explicit loop on array data structures in the code (using sub-contexts) instead of having a "foreach" loop statement in the template

Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-14 Thread Inkrementator via Digitalmars-d-learn
Hello, I am trying to derive a struct from another. I want to modify each field such that type of it goes from some T to Nullable!T, preserving all fieldnames and UDAs. I think that fieldnames and UDAs can only be duplicated via string-mixins. This means that all field-types that aren't

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread Inkrementator via Digitalmars-d-learn
On Friday, 15 March 2024 at 17:48:26 UTC, mw wrote: ``` $ dub build Could not resolve configuration for package demo ``` Trying to build your dependency msgpack-rpc, it spits out ``` Warning The sub configuration directive "vibe-d" -> [libevent] references a configuration that does not

Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-16 Thread Inkrementator via Digitalmars-d-learn
On Saturday, 16 March 2024 at 13:09:13 UTC, Adam D Ruppe wrote: On Thursday, 14 March 2024 at 23:19:37 UTC, Inkrementator wrote: @(__traits(getAttributes, thingYouWantToForward)) void yourNewThing() {} Thanks, that should solve my problem.

Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-16 Thread Inkrementator via Digitalmars-d-learn
On Friday, 15 March 2024 at 19:13:38 UTC, cc wrote: This is trivially easy if your types are visible at module level, and mixin is a fine tool for the job. It doesn't work quite so well with [Voldemort types](https://wiki.dlang.org/Voldemort_types). I used the following lines to make it work