Jonathan M Davis wrote:
On Friday 09 July 2010 23:31:18 Robert Jacques wrote:
A new statement can also allocate value types on the heap and return a
pointer to them. For example, the type of b and c is S1* and the GC
doesn't know about C's destructor. Please refer to the D spec on new
(http://www.digitalmars.com/d/2.0/expression.html#NewExpression) or TDPL
page 51. Both state that any type can be used with new; no limitations
with regard to reference or non-reference types are mentioned. Also, on
page 269 of TDPL there is an example of containing a Node*.

I guess that I missed that, though it doesn't help that I've read the class and struct chapters more recently, and they made a big deal about how classes were reference type and structs were value types and may no mention whatsoever of using structs on the heap - that and I rarely use pointers with primitive types even in C++, and I pretty much never use pointers in D. I think that I was thinking that you had to use malloc to put primitive types no the heap though. It never occurred to me to put a struct on the heap. Obviously, it's not a feature that I use often.

I don't mind that it be possible with new, but it is potentially confusing. Oh well, at least I'm aware of it now. If I ever want to use new in that manner though, I'm obviously going to have to study up on the subject more. I'm quite clear about how all that works in languages like C++ or Java, but D is a bit of a hybrid when it comes to memory management, and I obviously haven't pick up on all of its subtleties yet.

- Jonathan M Davis

Don't blame it on any lack on your part to pick up on D's subtleties;
I feel your pain also.

A clean programming language should aspire to removing such subtleties.

Recall the "D manifesto" on the D home page if one can call that
a manifesto.

<quote from-url="http://www.digitalmars.com/d/";>
D is a systems programming language. Its focus is on
combining the power and high performance of C and C++ with the
programmer productivity of modern languages like Ruby and Python.
Special attention is given to the needs of quality assurance,
documentation, management, portability and reliability.
</quote>

Now take challenge to that "manifesto" and ask "Who is kidding who?"

Sorry, Walter & Co, but there is a long way to go or otherwise
time to start over.  Even the Scala people have had the decency to
question themselves as to whether their language was an experiment.

See the Scala experiment:
lampwww.epfl.ch/~odersky/talks/popl06.pdf

My apologies for sometimes sounding pro-D and then sometimes
contra-D.  Overall I think that the goals of D are admirable
but then so much lost in the realization.

Cheers

Justin Johansson

Reply via email to