Classes in D with betterC

Luís Ferreira contact at lsferreira.net
Tue Nov 23 15:37:01 UTC 2021


On Tue, 2021-11-23 at 05:25 +0000, Stanislav Blinov via Digitalmars-d-
announce wrote:
> Have I? The article is named "Classes in D with betterC", the 
> preface states "Did you know that you can use classes in D as 
> better C? Yes, you read correctly, you can actually use classes 
> in D with -betterC." It's not at all clear that all you *really* 
> mean and want to address is instantiation thanks to 
> __traits(initSymbol).

Yes, maybe I expressed myself wrongly. Using only the term `use` can be
vague, but I don't think the article is as missleading as you painted.
What is the point of having classes without being possible to
instantiate them? I can see limitative usefulness on it if the only
objective on using D as better C is to expose a C++ API without
actually using it in better C. Plus, you can define the class
externally and just use it in better C.

The problem before `__traits(initSymbol)` is that you can't realisticly
use them in a fairly sane way. And by sane way I mean no need to
manually remove generated runtime hooks from a seperate non-betterC
compilation unit (`-defaultlib= -c`) or usage of `pragma(mangle)` to
simulate runtime TypeInfo.

I would say the sanest way of doing this is not even using custom
allocators and instead make `new` behave like C++ in D as better C, but
I'm not sure about the implications of that.

> Maybe it's a language or cultural issue? I'm not being bashful. 
> "Use classes", at least to me, means, well, "use classes", and 
> not "use a subset of classes that's really not much better than 
> structs as you can't fully support inheritance anyway because 
> destruction is a mess".
> 
> In other words, in order to fully appreciate the message of your 
> article, one has to already be aware of all the other issues. 
> Which is a dangerous presupposition for a public article, 
> especially not prefaced accordingly.

From what I understood the inheritance problem, destruction problem and
the other issues presented above are bugs of the implementation, not
the language itself.

-- 
Sincerely,
Luís Ferreira @ lsferreira.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20211123/29ef9bf4/attachment.sig>


More information about the Digitalmars-d-announce mailing list