Why are structs and classes so different?

Johan j at j.nl
Mon May 16 17:35:22 UTC 2022


On Sunday, 15 May 2022 at 16:36:05 UTC, Ali Çehreli wrote:
> On 5/15/22 08:26, Kevin Bailey wrote:
>
> > structs and classes are so different.
>
> I think a more fundamental question is why structs and classes 
> both exist at all. If they could be the same, one kind would be 
> sufficient. And the answer is there are value types and there 
> are reference types in programming.

What is very problematic is that you cannot see the difference in 
syntax. In my opinion it would have been much better if the 
language required using a `*` for class types: for example `Foo* 
a`, and `Foo a` would simply give a compile error.
A few years ago when I taught C++, this was 50% of the reason for 
me not to teach D. I see a big confirmation of that decision in 
this thread.

-Johan



More information about the Digitalmars-d-learn mailing list