As I’m working getting the @gc function attribute into D, the last remaining covariant attribute without contravariant inverse will be pure. The biggest question will not be how useful it is because its use will be exactly like that of other contravariant attributes (@system, throw, and @gc), no, the biggest question is syntax.
What are your preferences?
A few inspirations:
- Make
impurea hard keyword, sopureandimpurefalls into the same syntactical category asthrowandnothrow.
This has the downside of breaking code that has identifiers namedimpure. I’d guess those would be rare, though. - Make
@impurea compiler-recognized AtAttribute.
This has the downside of being asymmetric:purehas no@, but its inverse@impurewould have it. - Make
impurea contextual keyword, i.e. a compiler-recognized identifier with special meaning in certain places, similar tobody.
This has the downside that it breaks very specific code (e.g.int function() impure) and that it uses contextual keywords which Walter really doesn’t like. This option is interesting for the base language when Option 1 is pursued in the next Edition. - ―???―
Permalink
Reply