@safe fun alayws call @system function?

2016-07-12 Thread Dsby via Digitalmars-d-learn

How can i call @system function in a @safe function?


Re: @safe fun alayws call @system function?

2016-07-12 Thread ag0aep6g via Digitalmars-d-learn

On 07/12/2016 11:09 AM, Dsby wrote:

How can i call @system function in a @safe function?


You can't. You can mark the @safe function @trusted [1] instead. 
@trusted functions are considered memory-safe by the compiler and can be 
called from @safe code, but they can use @system features and call 
@system functions.


A @trusted function must still be memory-safe, and the compiler cannot 
check that it is, so you as the programmer take on the responsibility to 
ensure that the function is in fact memory-safe.


Be very careful with @trusted and make sure you know exactly what you're 
doing. A bad @trusted function compromises the whole call chain.



[1] https://dlang.org/spec/function.html#trusted-functions


Re: @safe fun alayws call @system function?

2016-07-12 Thread Dsby via Digitalmars-d-learn

On Tuesday, 12 July 2016 at 09:17:37 UTC, ag0aep6g wrote:

On 07/12/2016 11:09 AM, Dsby wrote:

How can i call @system function in a @safe function?


You can't. You can mark the @safe function @trusted [1] 
instead. @trusted functions are considered memory-safe by the 
compiler and can be called from @safe code, but they can use 
@system features and call @system functions.


A @trusted function must still be memory-safe, and the compiler 
cannot check that it is, so you as the programmer take on the 
responsibility to ensure that the function is in fact 
memory-safe.


Be very careful with @trusted and make sure you know exactly 
what you're doing. A bad @trusted function compromises the 
whole call chain.



[1] https://dlang.org/spec/function.html#trusted-functions


Thanks!