Nonconvex.jl icon indicating copy to clipboard operation
Nonconvex.jl copied to clipboard

Conflict with NLopt

Open pizhn opened this issue 4 years ago • 5 comments

optimize in Nonconvex will conflict with optimize in NLopt. Better resolve it when import both

pizhn avatar Jul 11 '21 01:07 pizhn

This is why I use import NLopt in the docs, not using. I don't think there is a better way to resolve this.

mohdibntarek avatar Jul 11 '21 04:07 mohdibntarek

https://discourse.julialang.org/t/two-modules-with-the-same-exported-function-name-but-different-signature/15231/2 Will this work?

pizhn avatar Jul 11 '21 04:07 pizhn

No because we can't extend NLopt's optimize without depending on it which I don't (it's an optional dependency) and NLopt can't do the same without depending on Nonconvex which also doesn't make sense. Also extending functions you don't own by dispatching on types you don't own is bad practice in Julia, called type piracy. It's bad because it modifies the behavior of code that may not have anything to do with Nonconvex. You can get away with it every once in a while but only when it's absolutely necessary and there is little risk.

mohdibntarek avatar Jul 11 '21 04:07 mohdibntarek

Would be nice to have a warning in the docs saying that you must use import not using.

mohdibntarek avatar Jul 11 '21 04:07 mohdibntarek

If you use using, you will need to use Nonconvex.optimize later.

mohdibntarek avatar Jul 11 '21 04:07 mohdibntarek