www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - About removing the new keyword

reply "Craig Black" <cblack ara.com> writes:
It seems that much of the community is for removing the new keyword, but 
Walter is not.  I've thought up a compromise that Walter may agree to and 
that would not require any syntax changes.  It's a very simple idea:

What if new could be defined as a template, but called without the ! so that 
the syntax for calling new would not change.

Just an thought.  May or may not be a good one.

-Craig 
Aug 29 2010
parent reply Daniel Gibson <metalcaedes gmail.com> writes:
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.
Aug 29 2010
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Daniel Gibson:
 Really? This is the first time I've heard about this.
 Why should it be removed anyway?
It was discussed a lot, and some people were about OK with the idea. The current new syntax is not nice looking, and maybe not necessary. The idea is to remove all not necessary things from D2 (if their absence doesn't uglify the code too much and doesn't reduce flexibility significantly). A problem is that to new you need to give three things: - optional placement, where to put the data - what type to allocate - an optional list of arguments for the constructor - and some people have asked for templated constructors, so this is the best chance to introduce this. Bye, bearophile
Aug 29 2010
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
I think it's nice when you want to differentiate between making a
struct/class object. Otherwise you'll end up doing:

C c; // This is a class object, not a struct!

Unless something else like templated constructors could help with
this, but I'm not sure what those are yet. :p

On Sun, Aug 29, 2010 at 7:43 PM, bearophile <bearophileHUGS lycos.com> wrot=
e:
 Daniel Gibson:
 Really? This is the first time I've heard about this.
 Why should it be removed anyway?
It was discussed a lot, and some people were about OK with the idea. The =
current new syntax is not nice looking, and maybe not necessary. The idea i= s to remove all not necessary things from D2 (if their absence doesn't ugli= fy the code too much and doesn't reduce flexibility significantly).
 A problem is that to new you need to give three things:
 - optional placement, where to put the data
 - what type to allocate
 - an optional list of arguments for the constructor
 - and some people have asked for templated constructors, so this is the b=
est chance to introduce this.
 Bye,
 bearophile
Aug 29 2010
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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. Andrei
Aug 29 2010
next sibling parent Daniel Gibson <metalcaedes gmail.com> writes:
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. Andrei
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?
Aug 29 2010
prev sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
I think that one is going as well (IIRC).

On Sun, Aug 29, 2010 at 8:49 PM, Daniel Gibson <metalcaedes 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. Andrei
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?
Aug 29 2010
parent reply Era Scarecrow <rtcvb32 yahoo.com> writes:
== Quote from Andrej Mitrovic (andrej.mitrovich 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 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
Aug 29 2010
parent "Paulo Pinto" <pjmlp progtools.org> writes:
Why not?

There are many examples of operating systems with
garbage collector built-in.


"Era Scarecrow" <rtcvb32 yahoo.com> wrote in > 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
Sep 01 2010