Escape analysis

Chad J gamerchad at __spam.is.bad__gmail.com
Tue Oct 28 16:46:08 PDT 2008


Steven Schveighoffer wrote:
> "Sergey Gromov" wrote
>> Walter Bright wrote:
>>> The first step is, are function parameters considered to be escaping by
>>> default or not by default? I.e.:
>>>
>>> void bar(noscope int* p);    // p escapes
>>> void bar(scope int* p);      // p does not escape
>>> void bar(int* p);            // what should be the default?
>>>
>>> What should be the default? The functional programmer would probably
>>> choose scope as the default, and the OOP programmer noscope.
>> I'm for safe defaults.  Programs shouldn't crash for no reason.
> 
> If safe defaults means 75% performance decrease, I'm for using unsafe 
> defaults that are safe 99% of the time, with the ability to make them 100% 
> safe if needed.
> 

If safe defaults means 2% performance decrease, I'm for using unsafe 
defaults that are safe 10% of the time, with the inability to make them 
100% safe if needed.

I might also be insane.

...

I'm initially biased towards the safe default.  I remember reading that 
part of D's design philosophy is to be safe by default, and I like that 
A LOT because it saves me from wasting many many hours of my life on 
stupid bugs.  I'm also not convinced that full closures really run that 
much slower.  That said, I'd be happy to ignore escape analysis for a 
while longer and just have D1 closures with the option to manually heap 
allocate them.  I say that under the assumption that it's really easy to 
implement, mostly sortof solves the problem, and allows better (more 
general, safer) solutions to be put in place later.



More information about the Digitalmars-d mailing list