Classes on stack

bauss jacobbauss at gmail.com
Thu Sep 1 12:25:00 UTC 2022


On Thursday, 1 September 2022 at 12:08:05 UTC, Redwan wrote:
> On Thursday, 1 September 2022 at 12:00:40 UTC, bauss wrote:
>> On Thursday, 1 September 2022 at 11:17:20 UTC, Redwan wrote:
>>> On Thursday, 1 September 2022 at 11:06:31 UTC, bauss wrote:
>>>> On Thursday, 1 September 2022 at 10:51:44 UTC, Redwan wrote:
>>>>> On Thursday, 1 September 2022 at 10:21:32 UTC, rikki 
>>>>> cattermole wrote:
>>>>>>
>>>>>> On 01/09/2022 10:13 PM, Redwan wrote:
>>>>>>> if it's for GC, how to completely disable gc? I don't Wan 
>>>>>>> use it at all. I searched for a compiler command line 
>>>>>>> disabling for gc but not found. GC.disable() is ugly way 
>>>>>>> I think.
>>>>>>
>>>>>> As long as you want to use things like classes and Phobos, 
>>>>>> you're stuck with the GC being linked in and active at 
>>>>>> some point in the lifetime of your process.
>>>>>>
>>>>>> D's runtime includes a lot of infrastructure such as 
>>>>>> threading that is initialized before your main ever 
>>>>>> executes.
>>>>>>
>>>>>> You can limit the GC activity by things like GC.disable, 
>>>>>> but its still linked in and in use at some point in time.
>>>>>>
>>>>>> D's GC is your friend, if you don't allocate it won't 
>>>>>> attempt to collect unless you want it to.
>>>>>
>>>>> well I know it's my friend, but we're just friend :) I 
>>>>> don't want to use it because it's uses alot of heap and I 
>>>>> don't like it. my case is special and all of heap usages 
>>>>> needs to be done by me. so I want to do something to avoid 
>>>>> this dynamic and runtime linkages and etc and be pure and 
>>>>> in my hand. definitely it must be some flags or 
>>>>> configurations to disable this stuff for a system language. 
>>>>> am I right?
>>>>
>>>> I already gave you the solution one message above; betterC 
>>>> (A subset of D) is what you want.
>>>
>>> yes sorry, I saw and I was reading about it, thank you.
>>>
>>> as I found, I can't use some important features in betterC. 
>>> like classes. but I need them.
>>
>> Are you sure you need classes and can't do with structs?
>
> I need inheritance and other OOP concepts and template 
> features. does D's struct support them? as I found, No.

Structs support templates fully, struct S(T) { ... } is supported.

Inheritance no, but you can sort of cheat with it using alias 
this.

You can probably achieve what you want without OOP, OOP isn't 
always the right choice and in most cases people confuse 
procedural programming with object oriented programming.


More information about the Digitalmars-d mailing list