Ranges and @safe

SrMordred patric.dexheimer at gmail.com
Sun Sep 22 23:40:10 UTC 2019

On Sunday, 22 September 2019 at 23:18:12 UTC, Paul Backus wrote:
> On Sunday, 22 September 2019 at 23:03:32 UTC, SrMordred wrote:
>> I think that .front in ranges should'nt be safe by default.
>> @safe{ iota(0,0).front(); } //BOOM, but compiles on @safe.
> @safe does not mean "does not have runtime errors", it means 
> "does not corrupt memory". Accessing the front of an empty 
> range may crash your program, but it shouldn't cause memory 
> corruption (unless you disable bounds-checking).

Hm.. yes.
Maybe i´m taking this on the wrong angle.
Maybe @safe should be more constraint then.

I feel like code under @safe should always be ok, and if any 
thing breaks you should look at
@trusted code to see where is the problem.
You "box" unsafe code on specific places (like Rust do with 

More information about the Digitalmars-d mailing list