DIP64: Attribute Cleanup

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 20 14:33:14 PDT 2014


On Fri, 20 Jun 2014 15:47:07 -0400, H. S. Teoh via Digitalmars-d  
<digitalmars-d at puremagic.com> wrote:

> On Fri, Jun 20, 2014 at 07:22:02PM +0000, Brian Schott via Digitalmars-d  
> wrote:
>> http://wiki.dlang.org/DIP64
>>
>> Attributes in D have two problems:
>> 1. There are too many of them and declarations are getting too verbose
>> 2. New attributes use @ and the old ones do not.
>>
>> I've created a DIP to address these issues.
>
> And while we're at it, why not also fix holes in attribute semantics on
> top of just fixing syntax?
>
> First, there is no way to mark a function as *impure* as opposed to pure
> (leaving out "pure" is not an option in template functions due to
> automatic attribute inference). Also, there's an inconsistency between
> positive attributes (pure, safe) vs. negative attributes (nothrow,
> nogc). So ideally, the new syntax should allow you to specify both pure
> and impure, and ideally, it should not special-case on peculiarities of
> the English language (pure/impure vs. throw/nothrow). So it should be
> something like @pure, @!pure, @throw, @!throw, @gc, @!gc, etc., for
> maximum consistency.

I like the idea, but seeing as how attribute sets already take arguments,  
it's natural to add them to builtins:

@pure(true) == @pure
@pure(false) == not @pure

-Steve


More information about the Digitalmars-d mailing list