Classes or stucts :: Newbie

Jonathan M Davis jmdavisProg at gmx.com
Sun Dec 19 14:38:17 PST 2010


On Sunday 19 December 2010 14:26:19 bearophile wrote:
> Jonathan M Davis:
> > There will be a library solution to do it, but again, it's unsafe.
> 
> It can be safer if the compiler gives some help. For me it's one of the
> important unfinished parts of D.

Whereas, I would argue that it's completely unnecessary. structs and classes 
serve different purposes. There is no need for scoped classes. They may 
perodically be useful, but on the whole, they're completely unnecessary.

The compiler can help, but it can't fix the problem any more that it can 
guarantee that a pointer to a local variable doesn't escape once you've passed 
it to another function. In _some_ circumstances, it can catch escaping pointers 
and references, but in the general case, it can't.

If we have library solutions for people who want to play with fire, that's fine. 
But scoped classes is just not one of those things that the language really 
needs. They complicate things unnecessarily for minimal benefit.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list