fix Issue 13662: @safe pure nothrow @nogc findRoot#2639
fix Issue 13662: @safe pure nothrow @nogc findRoot#2639MartinNowak merged 1 commit intodlang:masterfrom 9il:findroot
Conversation
|
Can you please file a bugzilla issue for the @safe @nogc nothrow thing. |
std/numeric.d
Outdated
There was a problem hiding this comment.
You should add an overload to make that work again or this change will break code.
Maybe it's possible to deprecate the overload at some point.
There was a problem hiding this comment.
I have no Idea how to make overload =(
This unittest was written by me for regression control (allow different R and T types in the same time). I think nobody use this style.
There was a problem hiding this comment.
Well just add a function with the old signature and forward it's implementation to the new find root.
std/numeric.d
Outdated
There was a problem hiding this comment.
copy-past:
I have no Idea how to make overload =(
This unittest was written by me for regression control (allow different R and T types in the same time). I think nobody use this style.
There was a problem hiding this comment.
What is the problem with this one? Why it doesn't work anymore?
There was a problem hiding this comment.
I see, link to original question : #2639 (comment)
There was a problem hiding this comment.
I am actually not sure why compiler can't find matching overload here, looks unambiguous.
There was a problem hiding this comment.
The template signature changed, so we need to add an overload with the old signature.
There was a problem hiding this comment.
If I add an overload for old signature than findRoot won't be compiled in most cases because there will be 2 suitable templates .
|
ping |
|
no idea =( |
|
I think we can push this commit as is or create something like |
There was a problem hiding this comment.
Doesn't the default argument work here?
Maybe in combination with a default type for DT?
There was a problem hiding this comment.
Compatible for delegates only, but not for other callable entities (functions, structs, objects).
|
So please add back the old signature as overload. T findRoot(T, R)(scope R delegate(T) f, in T a, in T b,
scope bool delegate(T lo, T hi) tolerance = (T a, T b) => false)
{
return find root!(T, typeof(f), typeof(tolerance))(f, a, b, tolerance);
} |
|
rebased |
|
Thanks @MartinNowak. This overload works (I thought it wouldn't work.)! |
Reason: allows findRoot be used in
@safe @nogc nothrowcode.