[REFACTOR] Maybe change the implementation syntax?
OvermindDL1 opened this issue · 4 comments
Currently an implementation head is something like:
defimplEx Integer, i when is_integer(i), for: Blah do
Since the name is put as a sub-namespace of the main protocol anyway, probably just simplify it to:
defimplEx Blah.Integer, i when is_integer(i) do
Actually I guess it should be
defimpl_ex Blah, for: i when is_integer(i), as: Integer do
Because in Elixir you do defimpl Inspect, for: MapSet, and not defimpl MapSet, for: Inspect. (Though I admit it feels reverse to me too, I suggest to rename yout macro defimpl_of !)
I would not use this:
defimpl_ex Blah.Integer, for: i when is_integer(i) do
Because how can we be sure what is the protocol and what is the sub-namespace module when reading defimpl_ex My.Awesome.Protocol.Accounts.Users.Admin ?
Isn't that the same as Elixir? The first argument is the protocol, the second is what you are implementing the protocol for?
Well I may have misunderstood your first post. I thought that Blah was the protocol and Integer the implementation type.
When you wrote
defimplEx Integer, i when is_integer(i), for: Blah do
To me it looks like Integer is a data type, and Blah is the protocol, so it is not the same as Elixir.