Skip to content

Conversation

@oschulz
Copy link
Contributor

@oschulz oschulz commented Jun 20, 2021

Always use unthunk instead.

Closes #374 .

Always use unthunk instead.
Copy link
Member

@mzgubic mzgubic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Have you checked if there are any references to calling thunks in the docs?

Let me know once you are happy so I can merge

function (x::InplaceableThunk)()
Base.depwarn("`(x::InplaceableThunk)()`` is deprecated, use `unthunk(x)`", :call_InplaceableThunk)
unthunk(x)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just replace both of these with

function (x::AbstractThunk)()
    Base.depwarn("`(x::AbstractThunk)()`` is deprecated, use `unthunk(x)`", :call_AbstractThunk)
    return unthunk(x)
end

?

Also, BlueStyle.jl uses explicit return

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, use AbstractThunk in the depwarn message for both of them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, should have been something like

function (x::T)() where T <: AbstractThunk
    Base.depwarn("`(x::T)()`` is deprecated, use `unthunk(x)`", :call_AbstractThunk)
    return unthunk(x)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can do that - ChainRulesCore is backward compatible with Julia v1.0, and (x::AbstractThunk)() = ... would require >= v1.3, right? And (x::T)() where T <: AbstractThunk = ... even v1.6 won't allow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking 1.0. With the risk of belabouring the idea:

for T in (:Thunk, :InplaceableThunk)
    @eval function (x::$T)()
        Base.depwarn("`(x::" * string($T) * ")()` is deprecated, use `unthunk(x)`", Symbol(:call_, $(T))) 
        return unthunk(x)
    end    
end

should work. Feel free to ignore if you think that the current way is better (but please do add return)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - just updated the PR, using this variant.


@testset "Deprecated: calling thunks should call inner function" begin
@test_deprecated (@thunk(3))() == 3
@test_deprecated (@thunk(@thunk(3)))() isa Thunk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also test InplaceableThunk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also test InplaceableThunk?

Well, we didn't before, but I can add it.

@oschulz
Copy link
Contributor Author

oschulz commented Jun 21, 2021

Have you checked if there are any references to calling thunks in the docs?

I hope I found and changed all of them ...

@mzgubic mzgubic merged commit 5e4b720 into JuliaDiff:master Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate function-call syntax for thunks

2 participants