structure inheritance and polymorphism

ryuukk_ ryuukk_ at gmail.com
Wed Jan 6 18:31:20 UTC 2021


On Wednesday, 6 January 2021 at 17:58:24 UTC, IGotD- wrote:

> Keep in mind that you can use classes without GC. For exampled 
> using the scoped macro or manually allocated.

but there is a big problem with that, is you need shop GC, and 
you need be careful because you can't enforce a @nogc globally, 
so you either tag every functions with @nogc wich is a pain and 
add noise everywhere in your files, sure you can have @nogc:  
bellow the module but it doesn't work for functions inside 
classes/structs


-betterC at least is enforced globally, so you don't think about 
hidden memory allocation that's gonna stack as your program lives


i believe interface with struct is a good idea because it avoids 
having to write lot of boilerplate to emulate vtables

or better, the concept of "signature", since most of the time, we 
use interface to make sure the type has that specific method..

interface on struct would lower barrier of entry by a LOT


More information about the Digitalmars-d mailing list