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

Translate "Add delete/1, mocked/0, and mocked_process/1" #4

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

paulo-ferraz-oliveira
Copy link
Contributor

@paulo-ferraz-oliveira paulo-ferraz-oliveira commented Jun 24, 2023

Translated(1) from 2Latinos/nuntius#28...

Notes on this implementation

  • 🟧 Credo has A LOT of non-default stuff
    • even though we may end up with a shorter rule list we wanna go full strict, at this moment, to test its/our limits
  • 🟩 macros ftw 🎉
    • even if small, in this context, so easily replaced by a function, I wanted to test this out, so went with it (don't hate me yet!)
  • 🟩 defdelegate for expressiveness/semantics
    • I'd used it in the past, in the context of behaviour implementations, and here it just feels like syntactic sugar (I'm not sure it's much more than that, though)
  • 🟧 . after function names
    • odd, when coming from the Erlang world, but easy to adapt to
  • 🟧 using & to pass a function reference
    • odd, when coming from the Erlang world, I think I'd preferred fn for consistency, but I get where the language's coming from
  • 🟩 if used
    • not common, for me, in Erlang, but easy to use in Elixir, since the syntax is much cleaner (if/else, instead of if/true)
  • 🟩 string interpolation
  • 🟩 @doc false
    • using this instead of @hidden or @private (since @doc is already what you use for regular doc.) is cleaner and makes a lot of sense
  • 🟧 jumping to Erlang via :
    • it probably wouldn't make sense to replicate all the Erlang public API in Elixir, but e.g. proc_lib and timer surely could do with some wrappers (this is just aesthetics for me, really 😄)
  • 🟧 defp/def
    • I quite like that Erlang modules' API is exposed at the top (and you don't have to mess with indentation when making something private/public), but there's (dis)advantages to both approaches
    • I miss rebar3 xref 😢
  • 🟩 tests' on_exit(
    • this is so much more ergonomic than init_per_testcase/end_per_testcase, so it's a win
  • 🟧 variable rebinding (^)
    • I don't love this (yet?): coming from an Erlang world and being used to "pinned by default": I shot myself in the foot twice while writing the tests (look at where ^ is used and you can see how easy it is to forget it and have the tests pass)
    • I wished https://www.erlang.org/eeps/eep-0055 would've gotten traction, implemented as a trial, and potentially faded out if the community at large disliked it...
  • 🟧 compile-time validations
    • there's some compile-time validations (like checking if a function exists) which are odd when coming from the Erlang world. While the "real world" problem is to potentially not load functions after they're used (and I guess that's what rebar3 xref is also used for) I am torn between having better compile-time validation and forcing me to use a compiler option to not have it (choices, choices, ...)

(1) an Erlang > Elixir translation, as presented here, is not a copy-paste exercise but rather a re-thinking of the implementation in a different language using that language's constructs as best as possible. The goal is to 1. make the API similar, 2. make it work, 3. make it idiomatic.

(and add missing ones, not default)

It's possible this list gets tweaked in the near future, but for now
we're issue-less which is what we aim for...
@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as ready for review June 24, 2023 15:01
@paulo-ferraz-oliveira paulo-ferraz-oliveira merged commit af6fd2a into main Jun 26, 2023
@paulo-ferraz-oliveira
Copy link
Contributor Author

Thanks. Merged!

@paulo-ferraz-oliveira paulo-ferraz-oliveira deleted the feature/next-steps branch June 26, 2023 10:00
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

Successfully merging this pull request may close these issues.

2 participants