Why are structs and classes so different?

Kevin Bailey keraba at yahoo.com
Mon May 16 20:48:10 UTC 2022


On Monday, 16 May 2022 at 19:06:01 UTC, Alain De Vos wrote:
> A new syntax like "*" should introduce something new.
> If it's not needed for classes why introduce it.

Hi Alain!

I have to sympathize with Johan. If you see:

Foo foo = get_foo();
call_function(foo);

can 'foo' change in 'call_function()' ? Is it by-reference or is 
it by value?

Foo* foo = get_foo();

How about now? Pretty obvious.

call_function(&foo);

Also obvious.

To re-phrase your claim, a new syntax doesn't need to introduce 
something new. Syntax is there to convey information.

> If you don't know if something is a class name it class_blabla.
> Just remember the effect of "="

ah, I see the problem. You've never worked in a large code-base 
written by thousands of other people. I do every day. I can't 
make them name things in any special way. But when I see the 
above code, I need to know exactly what it does with just a scan.



More information about the Digitalmars-d-learn mailing list