We just encountered something that seemed kind of odd, so I wanted to pass it by the list to see if it could be a possible feature.In Benchee we want to accept either a module or a function as an argument to a function. We'll have different behavior depending on the type there (since we're expecting any module passed in to implement a certain behaviour). However, there's no check for `is_module`. We were thinking of using `is_atom` (see here: https://github.com/PragTob/benchee/pull/148/files#diff-e8ef07ff6be58cfaaaf6f03420fc53e7R75), but that seems sort of confusing to me. I know technically modules are atoms, but would it be possible to have an `is_module` function that can be used in guard clauses and elsewhere that would more accurately convey the sort of thing we're trying to do?
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/8a823a05-3da0-4de8-b96c-273bd12297b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The closest thing we have is `Code.ensure_loaded/1`. If you don't check that the module exists, you're basically just checking that the input is an atom. And if you use ensure_loaded, you'll have a predicate function with side effects. You'd also break the expectation of guard safety with the `is_` prefix.
Would your `is_module/1` have different behaviour than `is_atom/1`? Would it be true only of atoms of the form `:"Elixir.SomeModule"`? I'm not sure it should, since `defmodule :random_atom` is valid.Which is a long way of saying, I think you should use `is_atom`. Perhaps with a line comment `# for modules`.
mån 16 okt. 2017 kl 20:02 skrev Devon Estes <devon....@gmail.com>:
We just encountered something that seemed kind of odd, so I wanted to pass it by the list to see if it could be a possible feature.--In Benchee we want to accept either a module or a function as an argument to a function. We'll have different behavior depending on the type there (since we're expecting any module passed in to implement a certain behaviour). However, there's no check for `is_module`. We were thinking of using `is_atom` (see here: https://github.com/PragTob/benchee/pull/148/files#diff-e8ef07ff6be58cfaaaf6f03420fc53e7R75), but that seems sort of confusing to me. I know technically modules are atoms, but would it be possible to have an `is_module` function that can be used in guard clauses and elsewhere that would more accurately convey the sort of thing we're trying to do?
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/8a823a05-3da0-4de8-b96c-273bd12297b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAAHw6CKCXb0Q67YMXFF0_fdcUaLvXWnAz5mLHEGFCZB%2BrU_J_Q%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Ctff5hfTWP7kQ8skvuoONNrCZ7Vj1eW0ZtibAzdEhOBHg%40mail.gmail.com.