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

Clarify deprecation of ^^^ #11590

Closed
QuinnWilton opened this issue Jan 24, 2022 · 3 comments
Closed

Clarify deprecation of ^^^ #11590

QuinnWilton opened this issue Jan 24, 2022 · 3 comments

Comments

@QuinnWilton
Copy link
Contributor

QuinnWilton commented Jan 24, 2022

Hello! In Elixir 1.12, ^^^ began outputting a deprecation warning:

iex(1)> import Bitwise
Bitwise
iex(2)> 3 ^^^ 5
warning: ^^^ is deprecated. It is typically used as xor but it has the wrong precedence, use Bitwise.bxor/2 instead
  iex:2:3

6

It isn't clear to me whether this warning is meant to indicate that ^^^ is deprecated entirely, or just in its use as a delegate for Bitwise.bxor/2. The fact that it calls out Bitwise.bxor/2 specifically makes me think that the deprecation is limited to that use, but the warning is output in all cases:

iex(1)> defmodule Operator do 
...(1)> import Kernel, except: [^^^: 2]
...(1)> def a ^^^ b, do: a + b
...(1)> end
warning: ^^^ is deprecated. It is typically used as xor but it has the wrong precedence, use Bitwise.bxor/2 instead
  iex:3:7

{:module, Operator,
 <<70, 79, 82, 49, 0, 0, 4, 248, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 140,
   0, 0, 0, 15, 15, 69, 108, 105, 120, 105, 114, 46, 79, 112, 101, 114, 97, 116,
   111, 114, 8, 95, 95, 105, 110, 102, 111, ...>>, {:^^^, 2}}
iex(2)> import Operator
Operator
iex(3)> 5 ^^^ 3
8
iex(4)> warning: ^^^ is deprecated. It is typically used as xor but it has the wrong precedence, use Bitwise.bxor/2 instead
  iex:3:3

nil
iex(5)> 

Note, also, that in the last snippet the warning is output after the result of the expression is printed, causing it to be rendered as part of the prompt for iex(4)>

I suppose my question is: is ^^^ going to be removed entirely in Elixir 2.0.0, and if so, should the warning be updated to reflect that more clearly?

@whatyouhide
Copy link
Member

@QuinnWilton let's wait for José but I'm pretty sure ^^^ is only deprecated as an alias for Bitwise.bxor/2 since it's gonna be in the operators list anyways. I agree that if that's the case we could improve the warning, thanks for reporting 💟

@josevalim
Copy link
Member

The operator will change precedence in Elixir v2.0.0 but not be removed. So my advice is to consider it as if it will be removed as the precedence change may break code.

@QuinnWilton
Copy link
Contributor Author

That makes sense, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants