minimal object.d implementation that allows classes

Mike Franklin slavo5150 at yahoo.com
Thu Dec 7 09:14:39 UTC 2017


On Wednesday, 6 December 2017 at 17:17:40 UTC, Luís Marques wrote:
> Is there a small druntime/object.d implementation that allows 
> basic support for classes, without bringing the whole druntime 
> implementation with it?

I can get away with just this 
(https://github.com/JinShil/stm32f42_discovery_demo/blob/master/source/runtime/object.d) in GDC.  It will likely cause LDC to crash (See https://github.com/ldc-developers/ldc/issues/781, https://github.com/ldc-developers/ldc/issues/552).  I haven't tested it with DMD.

But, I'm not really using classes in the typical way.  Instead, 
I'm more-or-less using them as namespaces with static 
polymorphism.  For an example, see 
https://github.com/JinShil/stm32f42_discovery_demo/blob/master/source/stm32f42/pwr.d

What you need in object.d will likely depend on how you intend to 
use your classes.  What's your use case?

Mike


More information about the Digitalmars-d mailing list