Re: Scope & Structs

2024-10-12 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 12 October 2024 at 13:11:52 UTC, Richard (Rikki) Andrew Cattermole wrote: You are not wrong, when it is a struct, it is being heap allocated. Sorry for prolonging the topic. I am very curious about your answers along with your patience... Can we say that structs are in the stack

Scope & Structs

2024-10-12 Thread Salih Dincer via Digitalmars-d-learn
I have a small program like below. Everything works as it should in classes; even if I call the structure with the new operator. But if I stop using classes, scope doesn't work properly! ```d class/* STEP2 struct//*/ Foo { this(int i) { i.writefln!"Object %s is created..."; } ~this()

Re: Scope & Structs

2024-10-12 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 12 October 2024 at 12:02:04 UTC, Salih Dincer wrote: ... even if I call the structure with the new operator. But if I stop using classes, scope doesn't work properly! Edit: It seems like scope is ineffective in structures. In fact, if there is the new operator, it is as if scope d

Re: Scope & Structs

2024-10-12 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 12 October 2024 at 13:08:03 UTC, Nick Treleaven wrote: If you want stack allocation of structs, why use `new`? Actually, I almost never use the new operator except with(). I was surprised because it seemed inconsistent here and wanted to share my experiment. On Saturday, 12 Oc

Re: Scope & Structs

2024-10-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
You are not wrong, when it is a struct, it is being heap allocated. Looks like the optimization for classes, hasn't been applied to structs. https://issues.dlang.org/show_bug.cgi?id=24806

Re: Scope & Structs

2024-10-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 13/10/2024 3:12 AM, Salih Dincer wrote: You are not wrong, when it is a struct, it is being heap allocated. Looks like the optimization for classes, hasn't been applied to structs. https://issues.dlang.org/show_bug.cgi?id=24806 So if |scope| is a facility for classes, it should

Re: Scope & Structs

2024-10-12 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 12 October 2024 at 12:10:17 UTC, Salih Dincer wrote: On Saturday, 12 October 2024 at 12:02:04 UTC, Salih Dincer wrote: ... even if I call the structure with the new operator. But if I stop using classes, scope doesn't work properly! Declaring a `scope SomeClass` initialized with `

Re: Splitting a project into different executable files

2024-10-12 Thread Monkyyy via Digitalmars-d-learn
On Saturday, 12 October 2024 at 01:09:56 UTC, Alexander Zhirov wrote: Is it possible to organize a project that will consist of several main files. I want to write several simple programs in one project, but for them to be divided into different files. So that it would be possible to choose dur