Attribute inference for auto functions?

Zach the Mystic reachzach at gggggmail.com
Wed Apr 17 21:58:29 PDT 2013


On Thursday, 18 April 2013 at 03:42:50 UTC, Piotr Szturmaj wrote:
> W dniu 18.04.2013 04:50, Zach the Mystic pisze:
>> On Thursday, 18 April 2013 at 02:40:42 UTC, Walter Bright 
>> wrote:
>>> On 4/16/2013 8:22 AM, Andrei Alexandrescu wrote:
>>>> There's a discussion that may be of interest to the larger 
>>>> community:
>>>> https://github.com/D-Programming-Language/dmd/pull/1877
>>>
>>> What do you think of this:
>>>
>>>     typeof(return) foo(int x) { return x; }
>>>
>>> ? That would only infer the return type, not the attributes.
>>
>> I don't actually have an opinion on whether attributes should 
>> be
>> inferred, but '@auto' (as opposed to '@infer') would be a 
>> relatively
>> innocuous way to do it explicitly instead of implicitly.
>
> And this can apply to whole scopes.

Yeah, that's true... 'typeof(return):' would not look good at the 
top of a file. I feel like this feature is attempting to turn on 
a vacuum, seeing how many explicit things can be sucked into the 
implicit vortex. I think the gold medal would be if there were a 
way to do everything implicitly, but some things may resist being 
sucked in, and for good reason. The syntax '@auto' seems like a 
bronze medal solution, so I'd be glad to see it lose to something 
better.


More information about the Digitalmars-d mailing list