accept @pure @nothrow @return attributes

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 27 13:03:34 PST 2015


On Tuesday, 27 January 2015 at 18:21:37 UTC, Nick Treleaven wrote:
> On 27/01/2015 18:01, Jonathan Marler wrote:
>> On Tuesday, 27 January 2015 at 17:18:11 UTC, Nick Treleaven 
>> wrote:
>>> On 27/01/2015 16:49, Jonathan M Davis via Digitalmars-d wrote:
>>>> abstract also applies to classes, as does final.
>>>
>>> Yes, but they actually only affect the *functions* belonging 
>>> to the
>>> class, not the variables. A class is not a variable.
>>>
>>
>> I think you may have missed the point.  I believe what 
>> Jonathan is
>> saying is that if you turn abstract into @abstract then you 
>> have to
>> consider how to solve the "abstract class" issue.  Do you 
>> change it to:
>>
>> @abstract class ?
>
> Yes, because it affects the class's functions, not its variable 
> members.
>
>> Same thing with final.  Since the same keywords are used in a 
>> lot of
>> different contexts, if you change how it is used in one 
>> context then
>> it's going to be inconsistent with how it's used in the other 
>> contexts
>> (like with a function or a class).  Then if you want 
>> consistency (which
>> is the point of why we are discussing this change in the first 
>> place)
>> you have to change every context it is used in. If you follow 
>> through
>> with your proposal, you'll end up putting a '@' character 
>> before almost
>> every keyword in the language
>
> In that case I don't think you've really grokked my proposal. 
> It only requires 5 changes to attributes for consistency (and 
> that's counting @pure and @nothrow).

Problem Summary: Using an '@' symbol for some function attributes 
and not others is weird.

void foo() pure @safe const;

Current Reason:  keywords don't use a '@' and non-keywords use a 
'@'

Your Solution: Have attributes that apply to variables use no '@' 
and all other attributes use a '@'.

You've changed the cutoff from "keywords" to "whether or not they 
apply to variables".  How does this solve the original problem 
(stated above)?

void foo() @pure @safe const;
// OR
public @pure final @safe foo();

How is this more consistent? This doesn't solve the problem is 
just shuffles around the cases when we use '@' and when we don't.

Note: not to mention that it still looks horrible to use '@'.  
There's no reason the language needs to require a '@' on a 
keyword.  The only reason is to make things consistent but if 
you're not making things more consistent, as shown above.


More information about the Digitalmars-d mailing list