impure
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Sat Apr 6 09:13:34 UTC 2024
On Friday, April 5, 2024 3:11:42 AM MDT Dom DiSc via Digitalmars-d-learn
wrote:
> On Sunday, 24 March 2024 at 09:16:20 UTC, Jonathan M Davis wrote:
> > So, yes, you've run into a problem that it would be nice to
> > have a better fix for, but even if we could negate attributes
> > in general, there are good reasons to prefer to avoid
> > mass-applying attributes.
>
> I don't see it as "mass-applying attributes" rather than changing
> the default to something more sane, so that I have to apply
> *less* attributes to any single function.
The core issue is that the place that is applying the attributes is far from
what they're being applied to, which makes it extremely easy to miss them
and not know which attributes are actually being applied - particularly when
reviewing code, since then you tend to be looking primarily at diffs and not
the entire file. It's going to be less of a problem with personal projects,
but with any project where multiple people work on the code, it can start
being a problem. Ultimately, having the attributes directly on what they
apply to tends to result in fewer maintenance issues - particularly with
larger projects.
> If the addition of new keywords (like "throws", "@gc" and
> "impure") is a problem, why not doing it like @nogc(false) or
> @nogc=false (likewise for nothrow and pure)?
There are a number of ways that it could be done, but regardless, we'd need
a DIP and an implementation, and neither has happened. It's a known problem
but hasn't been a big enough problem to have been made a priority.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list