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

ifelse is no longer a generic function #28

Closed
GunnarFarneback opened this issue May 23, 2018 · 5 comments
Closed

ifelse is no longer a generic function #28

GunnarFarneback opened this issue May 23, 2018 · 5 comments

Comments

@GunnarFarneback
Copy link
Contributor

JuliaLang/julia#27068 made ifelse a builtin function, so SIMD.jl can no longer add methods to it.

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0-DEV.5145 (2018-05-21 06:43 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit d8a1056 (2 days old master)
|__/                   |  x86_64-linux-gnu

julia> using SIMD
[ Info: Precompiling module SIMD
ERROR: LoadError: cannot add methods to a builtin function
Stacktrace:
 [1] top-level scope
 [2] include at ./boot.jl:314 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1069
 [4] include(::Module, ::String) at ./sysimg.jl:29
 [5] top-level scope
 [6] eval at ./boot.jl:317 [inlined]
 [7] macro expansion at ./none:3 [inlined]
 [8] top-level scope at ./<missing>:0
 [9] eval(::Module, ::Any) at ./boot.jl:317
in expression starting at /home/gunnar/.julia/v0.7/SIMD/src/SIMD.jl:873
ERROR: Failed to precompile SIMD to /home/gunnar/.julia/compiled/v0.7/SIMD.ji.
Stacktrace:
 [1] error at ./error.jl:33 [inlined]
 [2] compilecache(::Base.PkgId) at ./loading.jl:1221
 [3] _require(::Base.PkgId) at ./loading.jl:1005
 [4] require(::Base.PkgId) at ./loading.jl:876
 [5] require(::Module, ::Symbol) at ./loading.jl:871
@eschnett
Copy link
Owner

Thanks for the report. Overloading ifelse this way was a corner case to begin with.

Is there also a built-in function ifelse. (with a trailing dot)? According to the new convention, this is a better name anyway, as this function acts element-wise and does not return a single Bool.

@vchuravy
Copy link
Collaborator

I think that runs into the same problem, since we would need to overload broadcast(::typeof(ifelse), ...)
As an alternative I would propose the name select which is commonly used in the GPU world.

@GunnarFarneback
Copy link
Contributor Author

With regard to broadcasting I think the best option is to consider a Vec as a scalar, even if it internally holds multiple values, and be able to use broadcasting on arrays and tuples of Vec.

@GunnarFarneback
Copy link
Contributor Author

Those who have opinions about naming now have two alternative PRs to choose from. I'm neutral about it, but note that vifelse in the short term is the easier change since select is being deprecated from Base.

@GunnarFarneback
Copy link
Contributor Author

Resolved by #31.

doorisajar added a commit to nexteraanalytics/ConditionalJuMP.jl that referenced this issue Dec 17, 2018
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

No branches or pull requests

3 participants