Currently,
import <module>, only: <selector> accepts as a selector either:
- a keyword list of functions/arities
- :functions to import only all functions
- :macros to import only all macros
Additionally, the selector can be :sigils, which only imports a specific subset macros: those known to be sigils (based on the naming convention of defmacro sigil_...).
I propose extending the selector to allow
:guards, which would only import macros from the
<module> labelled as
@doc guard: true (including, automatically,
macros defined via defguard).
Similar to the __using__ and sigil__... macros, guards are a commonly-desirable-to-import subset of a module's macros. Additionally, this would reduce the cognitive dissonance between the fact that a macro defined as a defguard is not transparently a defmacro under the covers.
In programming, the hardest problems involve going from the 0 to 1 case, and the 1 to 2 case, after which hopefully you've solved for N + 1 cases. As an additional proposal, I propose supporting atom lists as a selector in import <module>, only: <selector>. This would elegantly allow for the common case of only importing high-value unqualified macros; namely: import <module>, only: [:sigils, :guards] without conflicting with the functions/arities keyword selector format. Mixing a :macro selector with either :sigils or :guards in an atom selector list would issue a compiler warning about the redundancy.
As former proposal handles my use-case, and the latter is a natural but not-required extension to the feature, I leave it for debate if a mixed atoms/keywords should be supported in the additional proposal: namely, something like import <module>, only: [:guards, sigil_URL]