make @safe "non-escapable"?
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed Feb 6 10:46:50 PST 2013
06-Feb-2013 22:26, Robert пишет:
> Making the following code illegal:
>
> import std.stdio;
> @safe {
> int test1() @system {
> int* p=new int;
> *p++=8;
> return 7;
> }
> }
>
> So if you mark code with @safe you can not mark parts of it to be
> @system. This would make things possible like compile time import of
> configurations, which would currently impossible in a safe way.
>
> For importing the config file you would simply do:
>
> @safe {
> mixin(import("app.cfg"));
> }
>
Nice example.
> Guaranteeing that the code in app.cfg has to be safe.
>
> I thought of some wrapper like safeImport() which searches the code for
> @system or @trusted and rejects the code if one of them is found. But
> this is quite hard to do it right, especially with mixin's. So it's
> probably best if the compiler handles this.
>
> What do you think. Should I file a bug report?
>
Yup.
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list