Should This Be An Error Instead Of A Warning?

30 views
Skip to first unread message

Onorio Catenacci

unread,
Apr 4, 2018, 1:39:35 PM4/4/18
to elixir-lang-core
Hi all,

I've been working through Lance Halvorson's book and I got to a point where I was trying to test the ability to join a phoenix channel via JS code.  I kept getting back an error to the effect that it couldn't find the join/3 function in the channel. The code he had was something like this:

def join("game:" <> game, _payload, socket) do
   {:ok, socket}
end

When I checked the Channel.join docs, I spotted that that second parameter is typespec'd as a map. I modified the parameter to %{} = _payload and sure enough everything worked as expected.

I then noticed that I was getting a compiler warning about join/3 not properly implementing the protocol. 

I'm sorry--I realize I'm being kind of vague. I just wanted to see if maybe that should be an _error_ not a warning.  Just wondering about opinions on this.

If my vagueness is too hard to follow for this conversation, I can dig up exact code and messages. :)


Onorio Catenacci

unread,
Apr 5, 2018, 9:37:06 AM4/5/18
to elixir-lang-core

It occurs to me that probably my question wasn't as clear as I hoped.

Right now when a function is not properly implementing the associated protocol I get a compiler _warning_.  Does anyone else feel (as I do) that it should actually be a compiler _error_?

José Valim

unread,
Apr 5, 2018, 10:29:22 AM4/5/18
to elixir-l...@googlegroups.com
The problem with an error is that you will break somebody else’s package when you add new callbacks to the behavior and protocol and that may be undesired. For example, Elixir v1.6 augmented Enumerable and there was no reason to break previous implementations. If we broke them, upgrading to v1.6 would be very hard.
--


José Valim
Founder and 
Director of R&D

Onorio Catenacci

unread,
Apr 5, 2018, 11:11:13 AM4/5/18
to elixir-lang-core
I just wondered why it was only a warning and not an error.  Thanks for explaining that José!

--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-core/Vf3VgAbxAg0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LYeJhFyyVEb%2BBPcgzqQPdz5nty8Cc77eAxxjNsbs4HMw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages