About the @export_to option: I wonder how often we define a module like `MyMainModule.Utils` where the idea is to export functionality to places other than `MyMainModule`.
To state this in a possibly clearer way: I see modules either: a) exporting all public functions to any callers. b) exporting all public functions to the module(s) in its parent naming stack. If other ways of exporting are not necessary, the logic of @export_to could be a lot simpler. Maybe another name, such as just saying `@protected` might be clearer in this case, but that is just semantics. Just my two cents. ~W-M On Wednesday, April 20, 2016 at 8:05:49 PM UTC+2, Myron Marston wrote: > > I find Elixir's warnings to be very, very helpful and on my projects I > have our CI builds configured to fail if there are any warnings. One of my > favorite warnings is this one: > > > lib/s3.ex:122: warning: function foo/1 is unused > > Elixir provides this warning when a private function is never used. I > love getting this warning as it helps me eliminate dead code. However, > there's a similar situation where Elixir does not provide a warning: when > private helper functions have been extracted into a helper module, and are > no longer called. In this case, the module is essentially a private module > and exists only to support some public interface (and perhaps support > multiple public modules). Elixir's source code has some examples like this: > > > https://github.com/elixir-lang/elixir/blob/v1.2.4/lib/elixir/lib/kernel/utils.ex > > I believe `Kernel.Utils` is meant to be a private module that serves only > to support public `Kernel` functionality (but is itself not meant to be > ever called by end-users). I'd like to propose that Elixir gain a new > `defmodulep` macro that would define a private module. Here's what I'm > imagining this would do: > > - Set `@moduledoc false`. > - Provide a "function is unused" warning when any of its public > functions have no callers in the project. If all of its public functions > are unused, it would be nice if it provided a "private module is unused" > warning instead of multiple "function is unused" warnings. > - Issue a warning when code in depending projects uses the private > module in any way. Alternately, we may want to totally disallow uses from > depending projects, but I think I'd prefer the warning. I would never > commit code that uses a private module from a dependency but it can be > useful to use it temporarily during a debugging session (or in iex or > whatever) so having a warning would allow this while making it clear to > the > user that they are doing something that is not recommended. > > Thoughts? > > Myron > > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/bda5555f-cc1e-4645-98e1-51e73d6833e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
