-
Notifications
You must be signed in to change notification settings - Fork 163
[Elixir] New concept exercise - protocols
#2122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this exercise, I think it addresses some of our previous concerns about this concept.
It also easily extends to a followup where the derived or fallback protocols can be taught.
@angelikatyborska Is there anything I can do to help with this PR? |
@ErikSchierboom I have to admit I didn't forget about this PR at all, but I've been struggling to find motivation to code at all in my free time in the past 2 months. If you have any tips on how to fix that problem, I could really use some 😞. I'll try to finish this PR in the upcoming week. |
Don't feel pressured by me to start coding in your free, just do whatever feels best for you. As for tips on how to fix that, maybe check in on the weekly meetings on Fridays? They can help get one enthusiastic. An alternative could be to work on some low hanging fruit, as in things that are easy to do and require just a little bit of your time. A final suggestion could be to team up with someone to work on something together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, I really like the conciseness of the introduction, the exercise makes sense, the after provides more context. This is a nice exercise. 🎉
|
||
## Implementing | ||
|
||
It is possible to implement protocols for all Elixir types: structs, `Tuple`, `Atom`, `List`, `BitString`, `Integer`, `Float`, `Function`, `PID`, `Map`, `Port`, `Reference`, and `Any`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should structs be within backquotes too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking is that it shouldn't because it differs from all the other items in that they can be substituted for Y in defimpl X, for: Y do
, but for structs you need to use the actual name of a struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the above reasoning. A C# example: "classes" should not be in backticks (it is not an actual keyword), but class
should be.
Co-authored-by: Tim Austin <tim@neenjaw.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great exercise!
This is my idea for the concept exercise about protocols. The draft includes the instructions, tests, and a sample solution.