Attribute inference for auto functions?

deadalnix deadalnix at gmail.com
Wed Apr 17 18:32:49 PDT 2013


On Wednesday, 17 April 2013 at 23:46:08 UTC, Walter Bright wrote:
> On 4/17/2013 3:20 PM, Timon Gehr wrote:
>>> "This is the same issue as defining a function with 'auto' in 
>>> one place
>>> and referring to it having a specific type/attribute in 
>>> another. So I
>>> think all the same arguments and reasoning discussed above 
>>> apply equally."
>>>
>>
>> Why is this a valid form of reasoning? The signature of a 
>> function that has its
>> return type inferred includes the function body.
>>
>> Furthermore, it is not the same issue. It is the dual issue. 
>> The distinction is
>> very relevant because pure and nothrow are designed in an 
>> asymmetric way,
>
> They are the same - adding the attribute retains covariance.
>

No : if a super function suddenly become pure because its 
implementation changed, then all kind of subclasses can broke. 
Generally, it is a bad idea for a super class to be aware of its 
subclasses.

But defining a function that is going to be overridden as auto is 
asking for trouble in the first place.


More information about the Digitalmars-d mailing list