Unfortunately we should not rely on the Docs chunk, because it is not 
expected to be available. We could add infrastructure to this but I would 
say only: :macros give a good enough approximation (and they'd cover 
patterns and guards).

On Sunday, October 22, 2023 at 7:31:27 AM UTC+2 christ...@gmail.com wrote:

> Sent early, oops.
>
> I leave it for debate if a mixed atoms/keywords should be supported in *the 
> additional proposal*: namely, how something like *import <module>, only: 
> [:guards, sigil_URL: 2]* would behave, and warn on overlap, for example 
> if *[:sigils, sigil_URL: 2]* was provided as a selector.
>
> On Sunday, October 22, 2023 at 12:27:21 AM UTC-5 Christopher Keele wrote:
>
>> 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* 
>> <https://github.com/elixir-lang/elixir/blob/927b10df80ee1c1c7396e68efe00d06bc3e80420/lib/elixir/lib/kernel.ex#L5684>
>> ).
>>
>> 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]*
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/623c24aa-6201-4f86-b5f3-993fbe576fb7n%40googlegroups.com.

Reply via email to