View mode: basic / threaded / horizontal-split · Log in · Help
September 20, 2012
Re: classes structs
I just wanted to reiterate what Steven has said here. If you will 
learn D with a plan to change it to your desires, you will be 
disappointed. That is not to say give no feedback, or attempt no 
change. For one, you are coming in way to late for a good number 
of changes (including when we go to v3). Steven already covered 
the other.


You will find that a lot has already been discussed, and many 
here have had their share of desires turned down. But we are here 
because D is not just moving in the right direction, for many it 
is already has great use-cases.

So welcome, and hopefully you'll stay.
September 20, 2012
Re: classes structs
On Thursday, 20 September 2012 at 01:42:26 UTC, David Currie 
wrote:
> On Tuesday, 18 September 2012 at 18:42:33 UTC, Timon Gehr wrote:
>> On 09/18/2012 07:07 AM, David Currie wrote:
>>> [ALL CAPS]
>>
>> It does not matter who is the loudest guy in the room. If you 
>> have a
>> point to make, just make it. (Stating the conclusion is not 
>> making a
>> point. Skipping forward and predicting polite refusal does not 
>> help.)
>>
>> Most of the statements in the OP are inaccurate.
>>
>> The best way to get in touch with the language is by reading 
>> the online
>> documentation and by experimenting with the compiler (prepare 
>> for some
>> bugs and unspecified corner cases). Reading the newsgroup 
>> helps too.
>>
>> Usually it is best to double-check any claims about the 
>> language
>> expressed online, using the reference implementation.
>
> Apologies for SHOUTING. I am unfamiliar with forum syntax and 
> etiquette
> I merely wished *stressing* some words.
>
> What is OP and perhaps why are most statements inaccurate?
> How does one get to the newsgroups. I only got here because 
> Walter gave
> me a link. I would gratefully welcome links.

OP = Original Post(er). They use a lot of abbreviations I don't 
know here: acronymfinder.com is your friend.

The only inaccurate statement I noticed was that class 
constructors are called (null is the default).

NMS
September 20, 2012
Re: classes structs
On 09/20/2012 03:43 AM, David Currie wrote:
> On Tuesday, 18 September 2012 at 18:42:33 UTC, Timon Gehr wrote:
>> On 09/18/2012 07:07 AM, David Currie wrote:
>>> [ALL CAPS]
>>
>> It does not matter who is the loudest guy in the room. If you have a
>> point to make, just make it. (Stating the conclusion is not making a
>> point. Skipping forward and predicting polite refusal does not help.)
>>
>> Most of the statements in the OP are inaccurate.
>>
>> The best way to get in touch with the language is by reading the online
>> documentation and by experimenting with the compiler (prepare for some
>> bugs and unspecified corner cases). Reading the newsgroup helps too.
>>
>> Usually it is best to double-check any claims about the language
>> expressed online, using the reference implementation.
>
> Apologies for SHOUTING. I am unfamiliar with forum syntax and etiquette
> I merely wished *stressing* some words.
>

I see. I wouldn't stress more than one or two words per post anyway.
It is fatiguing for the reader and tends to get annoying, without
strengthening the point.

> What is OP and perhaps why are most statements inaccurate?

This is the original post:

On 09/15/2012 12:19 AM, David Currie wrote:
> At the risk of appearing ignorant, I don't know everything about D.
> However in D I have noticed the following.
>
> It is a policy decision in D that a class is ALWAYS on the heap and passed
> by REFERENCE.

This is the default, but do as you wish.

> (I know there is a keyword to put a class object on the stack
> but this is not facile and needing a workaround is poor language design).

Built-in scoped classes are going away.

> This is effectively FORCED Java.

No. Forced means there is no other way.

> A D struct is on the stack

Not necessarily.

> and is NOT a class

Yes.

> and has NO inheritance.
>

Composition of value types and alias this achieve both inheritance and 
subtyping. There is no built-in method overriding facility for value
types, so just use function pointers.

> I have issues with this philosophy.
>
> It seems FUNDAMENTAL to me that a programmer needs both stack and heap
> objects

This is not fundamental. Stack objects are just 'nice to have'. If
there is an execution stack at all, of course.

> and should KNOW when to use each and should ALWAYS have a choice.
>

Well, he does. The preferred usage is prescribed at the declaration
site. The programmer who defines the type should know better, but his
decision can always be overridden if this appears to be fundamental.

> ALL struct VARIABLES when declared are initialised to their .init value.

Not all of them, no.

S s = void;

> Just in case a programmer "forgets" to initialize them.

No, unless a programmer "forgets" to not initialize them.

> This is like using a sledgehammer instead of a scalpel.

It is like defaulting to the sledgehammer when the scalpel is usually 
not appropriate.

> Could you answer me WHY??
> ALL classes when declared are instantiated on the heap
> and their constructor called.

No.

class C{} // no run time behaviour
C c; // initialized to null

> Again I ask WHY??
>
> Why can't the programmer have the freedom to build his own objects
> when he wants to with the compiler advising of errors ?
>

Because scoped classes conflict with the infinite lifetime model. One
programmer's freedom restricts another programmer. It is always a
matter of trade-offs. classes implement the Java model of OO.
structs have few limitations, and if absolutely needed can be used
together with unsafe constructs to [br|tw]eak the OO model. Depending
on who you ask, this may actually be undesirable.

The only way to get correct code is by proving it correct. Restricting
the constructs the programmer uses can make a proof easier, so this can
be a very good thing. Not that this would matter a lot for D at this 
point, of course, but reasoning about code is important even in
languages that make this notoriously difficult.

> Of course I have more to say about this but I need answers to these
> questions to proceed.
>



> How does one get to the newsgroups. I only got here because Walter gave
> me a link. I would gratefully welcome links.
>

Subscribe to news.digitalmars.com or use the web interface: 
http://forum.dlang.org/
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home