New @safe rule: defensive closures

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat May 28 11:20:55 UTC 2022


On Saturday, 28 May 2022 at 10:59:58 UTC, Dukc wrote:
> But woe to one who chooses `@system` just to "be higher level". 
> While it does enable slightly shorter code in some cases, much 
> more time will be lost debugging the error-prone practices it 
> leads to. It's just as "good" choice as not using function 
> prototypes in a new C codebase because it saves some LOC.

What I mean is that DSP code will most likely be @system, but the 
UI could essentially be written in C#, so it would be acceptable 
to limit @safe to high level constructs and put the burden on 
@system code calling @safe code (eg provide owning pointers and 
other useful constructs). That has value.

I am not sure if there is all that much value in making low level 
code @safe, if you look at status quo for research languages... 
that is a tall mountain to climb and not a pretty view.



More information about the Digitalmars-d mailing list