Why is `scope` planned for deprecation?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Nov 18 16:04:47 PST 2014


On 11/18/2014 1:56 PM, "Ola Fosheim Grøstad" 
<ola.fosheim.grostad+dlang at gmail.com>" wrote:
> Filenames are easy, just allocate a large fixed size buffer, then fill in.
> open(). reuse buffer.

     char s[] = "filename.ext";
     foo(s[0..8]);

But hey, it's simpler, faster, less code, less bug prone, easier to understand 
and uses less memory to:

1. strlen
2. allocate
3. memcpy
4. append a 0
    foo
5. free

instead, right?

I know you said "just allocate a large fixed size buffer", but I hope you 
realize that such practice is the root cause of most buffer overflow bugs, 
because the "640K is enough for anyone" just never works.

And your "just use a struct" argument also promptly falls apart with:

     foo("string")

Now, I know that you'll never concede destruction, after all, this is the 
internet, but give it up :-)



More information about the Digitalmars-d mailing list