Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add invokelatest from Julia 0.6 #352

Merged
merged 2 commits into from
Apr 28, 2017
Merged

add invokelatest from Julia 0.6 #352

merged 2 commits into from
Apr 28, 2017

Conversation

stevengj
Copy link
Member

This adds Compat.invokelatest for the Base.invokelatest function introduced in JuliaLang/julia#19784

@stevengj stevengj requested a review from yuyichao April 27, 2017 13:27
README.md Outdated
@@ -165,6 +165,10 @@ Currently, the `@compat` macro supports the following syntaxes:

* `bswap` is supported for `Complex` arguments on 0.5 and below. ([#21346])

* `Compat.invokelatest` is equivalent to `Base.invokelatest` in Julia 0.6,
but works Julia 0.4+, and allows you to guarantee that a function call
Copy link
Member

Choose a reason for hiding this comment

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

"works on Julia 0.4+" (or "in"?)

Copy link
Member Author

Choose a reason for hiding this comment

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

whoops, fixed.

if isdefined(Base, :invokelatest)
import Base.invokelatest
else
invokelatest(f, args...) = eval(Expr(:call, f, map(QuoteNode, args)...))
Copy link
Member

Choose a reason for hiding this comment

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

While this surely is the correct definition for invokelatest, prior to JuliaLang/julia#17057 just f(args...) would often also work and be more performant. I'd surely have use for a function that does just f(args...) in older Julia and invokelatest (or eval(...)) in newer Julia. Should we include this in Compat?

Copy link
Member Author

@stevengj stevengj Apr 27, 2017

Choose a reason for hiding this comment

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

@martinholters, that's not true. Prior to that PR, you might get some random obsolete version of a function. See, for example JuliaLang/julia#7884 ... we had to add something like this in IJulia long before 17057.

Copy link
Member

Choose a reason for hiding this comment

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

I know. But I use eval to create anonymous functions for which there cannot be obsolete versions. But that might be a very specific use case of mine.

Copy link
Member Author

@stevengj stevengj Apr 27, 2017

Choose a reason for hiding this comment

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

The point is, this seems to be about the simplest correct definition of invokelatest on earlier Julia versions. Your suggestion above would not work in general, hence it is not appropriate for Compat.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the misunderstanding: I didn't want to propose replacing what you have done, merely suggest to consider the simplified definition in addition. But admittedly, it doesn't really fit into Compat and I have no API proposal, so let's forget about it.

@stevengj
Copy link
Member Author

Travis failure on 0.4 OSX seems unrelated:

The command "curl -A "$CURL_USER_AGENT" -s -L -o julia.dmg 'https://s3.amazonaws.com/julialang/bin/osx/x64/0.4/julia-0.4-latest-osx10.7+.dmg'" failed and exited with 56 during .

@stevengj
Copy link
Member Author

Okay to merge?

@stevengj stevengj merged commit 594fafc into master Apr 28, 2017
@stevengj stevengj deleted the invokelatest branch April 28, 2017 18:41
martinholters added a commit that referenced this pull request Sep 10, 2018
fredrikekre pushed a commit that referenced this pull request Sep 14, 2018
* `zeros` and `ones` with interface of `similar` (from #330)

* `convert` between `Set` types (from #342)

* `isassigned(::RefValue)` (from #345)

* `unsafe_trunc(::Type{<:Integer}, ::Integer)` (from #344)

* `bswap` for complex numbers (from #346)

* Compat.StringVector (from #348)

* `invokelatest` (from #352 and #359)

* Misc. pre-0.6-only code

* obsolete README enries
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.

2 participants