forcing "@nogc" on class destructors

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 20 10:25:33 PST 2015


On Tue, 20 Jan 2015 18:17:56 +0000
Meta via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On Tuesday, 20 January 2015 at 18:12:27 UTC, ketmar via 
> Digitalmars-d wrote:
> > Hello.
> >
> > as there is no possibility to doing GC allocations in class
> > destructors, wouldn't it be nice to just force "@nogc" 
> > attribute on
> > such dtors?
> >
> > i know, i know, "this will break alot of code". i'm pretty sure 
> > that
> > this will break alot of INVALID code, which better be broken at
> > compile-time anyway.
> >
> > sure, we have alot of code of pre- at nogc era, and alot of code 
> > where
> > authord didn't bother to add attributes at all. so we can 
> > introduce
> > "--force-dtor-nogc" CLI arg and document this change, making it 
> > opt-in
> > for, say, six month and opt-out after that.
> >
> > and i know that D devs (Walter at least) are resistant to 
> > command-line
> > flags that changing compiler behavior. i don't know how to 
> > overcome
> > this. say, by adding "@gc" attribute, which dfix can 
> > automatically add?
> >
> > but i still believe that instead of telling people again and 
> > again that
> > they should not allocate in class destructors, we can use 
> > computer
> > itself to track and stop this behavior.
> >
> > let's see how this proposal will be rejected. will there be 
> > some sane
> > reasons, or only the good old song about "broken code"? make 
> > your bets!
> 
> Isn't this just an implementation detail of the current garbage 
> collector? If so, then we shouldn't tie language semantics to it, 
> as it could change.
how likely this to be changed? is there *any* chances of that in 2015?
2016? and why we can't just remove that restriction when new GC will be
implemented? removing the "@nogc" requirement on class dtors will break
*nothing* *at* *all*. yet adding it now, while we don't have that new
GC, will prevent alot of bugs that can slip in crack.

btw, you won the prize of not talking about "broken code"! sadly, i
forgot to setup the prizes... anyway, thanks for sane argument.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150120/5d5ad26a/attachment.sig>


More information about the Digitalmars-d mailing list