OT: C# now has ref and const ref return

SashaGreat s at g.com
Wed Aug 7 13:57:07 UTC 2019


One thing that bothers me is the fear of breaking code and 
perpetuating bad design.

C++ motto is exactly this, they don't break code and they keep 
with backwards compatibility.

Some will say this motto was the reason of the success of C++. I 
don't know, I think the real reason was compatibility with C and 
OO back in the day, since the next contender was Java (I'm 
talking about 90's).

But look how horrible C++ is, a lot of developers say this too.

Imagine there is o topic on Bjarne's website explaining: "Should 
I put "const" before or after the type?"

Some of Bjarne's answers:

"I put it before, but that's a matter of taste. "const T" and "T 
const" were - and are - (both) allowed and equivalent. For 
example:
	const int a = 1;	// ok
	int const b = 2;	// also ok"

"Why? When I invented "const" (initially named "readonly" and had 
a corresponding "writeonly"), I allowed it to go before or after 
the type because I could do so without ambiguity. Pre-standard C 
and C++ imposed few (if any) ordering rules on specifiers.

I don't remember any deep thoughts or involved discussions about 
the order at the time."


Unfortunately that persists till today.

Rust will try another thing, every 2~3 years they will revise 
their design and if needed they will indeed break things.

We will see how this will end.

I think D with a very smaller user base than C/C++/Java should be 
guided by better design even it will break code, yes it's hard 
but I'd prefer a nice and clear one than another C++ language.

Maybe D3?

Sasha.


More information about the Digitalmars-d mailing list