Allow Explicit Pointer for Auto Declaration

Meta via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 30 06:37:43 PDT 2016


On Thursday, 29 September 2016 at 23:42:29 UTC, Jacob wrote:
> Was wondering if this feature could be implemented, right now 
> auto needs to be written like this:
>
>     auto pValue = someFunctionReturnsRef(); // forgot '&', 
> still valid
>                                             // makes a copy 
> when we didn't want one
>
> The feature would make the code look like this:
>
>     auto* pValue = someFunctionReturnsRef(); // error expecting 
> pointer
>
> We don't accidentally make a copy when we wanted a pointer. C++ 
> has a similar semantic for it's auto.

This suggestion has come up before but Andrei is against it.

https://github.com/dlang/dmd/pull/3615

It brings a tear to my eye.


More information about the Digitalmars-d mailing list