D mentioned on Rust discussions site

Walter Bright newshound2 at digitalmars.com
Sat May 23 02:37:23 UTC 2020


On 5/22/2020 2:22 AM, Henrik wrote:
> do you find the ideas of the restrict keyword and VLA bad, or only the current 
> implementation in C99?

I've done some experiments with restrict in gcc, examined the generated code, 
and found the optimizations it does and does not do baffling. I wonder if 
perhaps it is used so little that nobody really bothered to get the semantics right.

VLA just sucked from beginning to end.


> If the ideas are good, how would you have implemented 
> them instead?

Restrict working requires great care on the part of the programmer to not make a 
mistake with it, as it is unchecked by the compiler. Which means the vast 
majority of users will just introduce subtle bugs when they try it. Which means 
no sane programmer will use it.

VLA relies far too much on the vagaries of the stack implementation. Hence it's 
unportable and unreliable.

C missed some obviously great ideas. One is nested functions, which fit right in 
with C's semantics. The other is the fix for:

https://www.digitalmars.com/articles/C-biggest-mistake.html

C89's adoption of function prototypes was a home run, but note I said adoption, 
not invention. They were invented by C++, and C compiler vendors (like mine) 
added them to C, and the committee just stamped its approval on it. C has 
resisted anything else that hails from C++.


More information about the Digitalmars-d mailing list