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

[REFACTOR] Maybe change the implementation syntax? #7

Open
OvermindDL1 opened this issue Mar 30, 2018 · 4 comments
Open

[REFACTOR] Maybe change the implementation syntax? #7

OvermindDL1 opened this issue Mar 30, 2018 · 4 comments

Comments

@OvermindDL1
Copy link
Owner

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
@lud
Copy link

lud commented Sep 15, 2020

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 ?

@OvermindDL1
Copy link
Owner Author

Isn't that the same as Elixir? The first argument is the protocol, the second is what you are implementing the protocol for?

@lud
Copy link

lud commented Sep 23, 2020

Well I may have misunderstood your first post. I thought that Blah was the protocol and Integer the implementation type.

@lud
Copy link

lud commented Sep 29, 2020

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.

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

2 participants