> How would you make the distinction between a guard and a regular macro?

This is exactly the root issue for me. :( I am not sure if we should rule
out macros, just because they are not written with defguard.

On Mon, Jun 13, 2022 at 21:42 'eksperimental' via elixir-lang-core <
elixir-lang-core@googlegroups.com> wrote:

> > Would you think it would make sense to _exclude_ any 'guard macros'
> > either NOT defined with `defguard` nor having whatever relevant
> > attribute there might be?
>
> How would you make the distinction between a guard and a regular macro?
>
> > I'm trying to think how useful this
> > request/proposal might be for others. Personally, I'm generally happy
> > to just `import` specific macros/guards if it doesn't make sense to
> > just import entire modules.
>
> My use case if that usually the only thing that I import from an
> `*.Util` module are the guards
>
> > I would think `import`-ing a module would also include any guards (of
> > any variety) – is that no so?
>
> Well, `import only: :macros` would import the guards, since they are
> macros, but it will also import any other macro that may you have.
>
> On Mon, 13 Jun 2022 12:25:27 -0700 (PDT)
> Kenny Evitt <kenny.ev...@gmail.com> wrote:
>
> > Those are good details to know – thanks!
> >
> > And thanks for pointing out my 'brain fart' about `defguardp`.
> >
> > Would you think it would make sense to _exclude_ any 'guard macros'
> > either NOT defined with `defguard` nor having whatever relevant
> > attribute there might be? I'm trying to think how useful this
> > request/proposal might be for others. Personally, I'm generally happy
> > to just `import` specific macros/guards if it doesn't make sense to
> > just import entire modules.
> >
> > I would think `import`-ing a module would also include any guards (of
> > any variety) – is that no so?
> >
> > On Monday, June 13, 2022 at 12:44:09 PM UTC-4 eksperimental wrote:
> >
> > > As of now, when you define a guard with `defguard` it adds the
> > > attribute: `@doc guard: true`, we could include guards that are
> > > defined with `defguard` and any other macros with this attribute
> > > set. Or we could introduce a new attribute for identifying guards,
> > > as @doc seems limited to documentation only.
> > >
> > > `defguardp` are private so they wouldn't be available to be
> > > imported.
> > >
> > > On Mon, 13 Jun 2022 09:21:39 -0700 (PDT)
> > > Kenny Evitt <kenny...@gmail.com> wrote:
> > >
> > > > So the `:guards` option would only import guard macros?
> > > >
> > > > Should this option also import guards that are NOT defined using
> > > > `defguard` or `defguardp`?
> > > >
> > > > On Monday, June 13, 2022 at 10:02:46 AM UTC-4 eksperimental wrote:
> > > >
> > > > > Hi,
> > > > > Currenly import/1 allows us to import :functions, :macros,
> > > > > :sigils with the :only option.
> > > > > I have found myself to manually have to list every guard I want
> > > > > to import from my "Util" module. This has been a recurring
> > > > > issue.
> > > > >
> > > > > I think it will be a good addition given the nature of guards
> > > > > that since they are macros they need to be required, plus
> > > > > usually you don't want to have the module name when you call
> > > > > the guard.
> > > > >
> > > > > What do you guys think?
> > > > >
> > > >
> > >
> > >
> >
>
> --
> 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/62a79330.1c69fb81.761ec.1654SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
>

-- 
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/CAGnRm4K1a-Tm20CGxGYaejuOrsS%3DVDm%3DaWPkYXebwcQnS-8tRA%40mail.gmail.com.

Reply via email to