Why is `scope` planned for deprecation?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 18 13:11:26 PST 2014


On 11/18/2014 12:53 PM, Paulo Pinto wrote:
> On Tuesday, 18 November 2014 at 19:45:12 UTC, Walter Bright wrote:
>> (C has added useless enhancements, like VLAs.)
>
> So useless that it became optional in C11.
>
> https://groups.google.com/forum/#!topic/comp.std.c/AoB6LFHcd88

Note the Rationale given:

---

- Putting arbitrarily large arrays on the stack causes trouble
in multithreaded programs in implementations where stack growth
is bounded.

- There's no way to recover from an out-of-memory condition when
allocating a VLA.

- Microsoft declines to support them.

- VLAs aren't used much.  There appear to be only three in
Google Code, and no VLA parameters. The Linux kernel had one,
but it was taken out because there was no way to handle an
out of space condition.  (If anyone can find an example of
a VLA parameter in publicly visible production code, please
let me know.)

- The semantics of VLA parameters is painful.  They're
automatically reduced to pointers, with the length information
lost.  "sizeof" returns the size of a pointer.

- Prototypes of functions with VLA parameters do not have
to exactly match the function definition. This is
incompatible with C++ style linkage and C++ function
overloading, preventing the extension of this feature
into C++.

                         John Nagle



More information about the Digitalmars-d mailing list