@safe by default

Steven Schveighoffer schveiguy at yahoo.com
Sat Jun 16 18:47:10 UTC 2018


On 6/16/18 10:02 AM, Jacob Shtokolov wrote:
> On Saturday, 16 June 2018 at 13:57:48 UTC, Bastiaan Veelo wrote:
>> On Saturday, 16 June 2018 at 13:52:37 UTC, Jacob Shtokolov wrote:
>>> Is it possible to introduce a new parameter/flag to the compiler, to 
>>> force all functions be @safe by default on a per-module basis?
>>>
>>> For example:
>>>
>>> ```
>>> module mymodule;
>>>
>>> pragma(safe);
>>
>> We already have that, and with even shorter syntax:
>>
>> ```
>> module mymodule;
>>
>> @safe:
>>
>> [...]
>> ```
>>
>> :-)
> 
> OMG! Didn't know that! xD
> 
> Thank you Bastiaan!

I would just caution that this does not affect member functions, only 
module-level functions. You have to repeat the @safe: inside any structs 
or classes as well.

-Steve


More information about the Digitalmars-d mailing list