Why are structs and classes so different?

Ali Çehreli acehreli at yahoo.com
Mon May 16 21:20:43 UTC 2022


On 5/16/22 10:35, Johan wrote:

 > 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.

I see. Is it really a high mental load without the syntax? I seems to 
just work in my programs but perhaps because I am the main programmer 
and classes are very rare anyway.

Also, same syntax is said to help with template code but perhaps the 
argument there is a template must be written either for value types or 
reference types? I am not sure.

 > A few years ago when I taught C++, this was 50% of the reason for me not
 > to teach D.

That's unfortunate. :(

 > I see a big confirmation of that decision in this thread.

Luckily, in my experience such threads are not frequent. Still, we may 
see a related topic at DConf. ;)

Ali



More information about the Digitalmars-d-learn mailing list