Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Could somebody explain the @impl feature in a little more detail. I'm confusing the terminology of callback functions I think.


Before this change, if you wrote a module (let's call it MyFoo) that implemented a behaviour, your only clue would be the `@behaviour Foo` near the top. All the functions in MyFoo would look the same; you'd need to look in the Foo module to look at Foo's list of callbacks if you wanted to know which of MyFoo's functions implemented Foo's callbacks.

Now with this change, you are free to mark those functions in MyFoo with `@impl true`. It's entirely opt-in, but once you use it, it enforces the presence of `@impl true` on all MyFoo's callback implementations. This allows the programmer to make these functions' purpose clear, and uses the compiler to make sure the annotations aren't stale or incorrect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: