Declaring Ref Variables Inside Function Calls

Simen Kjaeraas simen.kjaras at gmail.com
Tue Mar 31 09:07:00 PDT 2009


dsimcha <dsimcha at yahoo.com> wrote:

> == Quote from Denis Koroskin (2korden at gmail.com)'s article
>> That said, I don't think there is a need for something like this.
>> Certainly no speedup and little clarity compared to declaring variable
>> right before invoking doStuff.
>
> Here's an example of where it would be a useful piece of sugar, given an  
> unpack
> function that I was playing with:
>
> // How it works now:
> uint foo;
> string bar;
> unpack(foo, bar) = someFunction();
>
> // vs. how I want it to work:
> unpack(auto foo, auto bar) = someFunction();

If foo and bar die right after this line, I feel this is acceptable.
But declaring variables inside a function call seems to me hard to
decipher and hardly ever a good idea.

--
Simen



More information about the Digitalmars-d mailing list