About removing the new keyword

Era Scarecrow rtcvb32 at yahoo.com
Sun Aug 29 21:10:54 PDT 2010


== Quote from Andrej Mitrovic (andrej.mitrovich at gmail.com)'s article
> I think that one is going as well (IIRC).
> On Sun, Aug 29, 2010 at 8:49 PM, Daniel Gibson <metalcaedes at gmail.com> wrote:
> > Andrei Alexandrescu schrieb:
> >>
> >> On 08/29/2010 11:28 AM, Daniel Gibson wrote:
> >>>
> >>> Craig Black schrieb:
> >>>>
> >>>> It seems that much of the community is for removing the new keyword,
> >>>
> >>> Really? This is the first time I've heard about this.
> >>> Why should it be removed anyway?
> >>>
> >>> There has been some discussion about removing "delete" (is there any
> >>> definite decision on that yet?) though.
> >>
> >> The definite decision is delete will be deprecated following a staggered
> >> schedule (deprecated for six months, removed thereafter). Walter didn't have
> >> the time to get to that.
> >>
> > Ok.
> > If delete is removed, how will Explicit Class Instance Allocation (
> > http://www.digitalmars.com/d/2.0/memory.html#newdelete ) work? Isn't delete
> > needed for that?
> >

  In my opinion and thoughts (although they may be wrong or misguided), wouldn't
removing 'new'
be a bad thing? I suppose you could live without it; however the syntax may get
larger and maybe
more unsightly (or more complex rules) to compensate for it which is counter
productive. Also 'new'
is a declaration and a reminder of intent; you know your creating an object and
the compiler wouldn't
have to do anything extra. Besides, keeping it a simple and better structured
language (code and compiler wise)
is what i think makes D such a wonderful language.

  As for delete, 95%+ of the time with a garbage collector you don't need it.
However you can still turn off the garbage collector. Since you can (and if you do)
and there's no way to manually free the resources, If your program is memory hungry
it would be eventual your program finishes properly or crashes from no memory left.
In instances of manual control (Say a private inner class) where reference can't go
outside of the class, and can guarantee no other references to the object may want
to use delete. Also since this is a OS building language, i wouldn't expect a garbage
collector in that instance at all.

  So, Delete should just be discouraged, not removed.

 Era


More information about the Digitalmars-d mailing list