Time to start compiling with -dip25
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Jan 1 00:36:29 UTC 2019
On Fri, Dec 28, 2018 at 05:08:32PM -0800, Walter Bright via Digitalmars-d wrote:
> As it's going to become the default behavior. Maybe not in the next
> release, but soon.
>
> Here are some examples of how to upgrade your code, is usually means
> adding `return` here and there.
>
> https://github.com/dlang/dmd/pull/9154
So, today I decided to take a shot at testing one of my smaller projects
with -dip25. It appears that -dip25 really only has a real effect when
in @safe code, so I tried marking my code @safe.
Unfortunately, it has been an exceptionally frustrating experience and I
have run into a roadblock: I have a pair of mutually-recursive template
functions:
auto func1(R)(R range)
{
...
range.func2();
...
}
auto func2(R)(R range)
{
...
range.func1();
...
}
Unsurprisingly, the compiler was unable to infer @safe for these
functions, since their mutual dependency understandably makes it hard
for automatic inference to deduce @safe correctly. However, there is no
workaround for this that I know of: I cannot mark these functions as
@safe because *sometimes* I need to call them with R = a @system type,
primarily std.stdio.ByLine -- why that is not @safe is a can of worms
I'm not sure I want to open right now; but the bottom line is, sometimes
R needs to be a @system type, but there is currently no nice way in the
language to express the concept "this template function is @safe unless
template argument R is @system".
This is an impasse that hinders further progress, so at this point, I
have no choice but to give up on making more of my code @safe. Which
also means, as far as I'm concerned, that -dip25 is worth almost nothing
to me right now. :-(
T
--
Nearly all men can stand adversity, but if you want to test a man's character, give him power. -- Abraham Lincoln
More information about the Digitalmars-d
mailing list