void init of out variables
Nicholas Wilson via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 18 23:24:22 PDT 2017
On Saturday, 19 August 2017 at 06:23:10 UTC, Igor Shirkalin wrote:
> On Saturday, 19 August 2017 at 06:20:28 UTC, Nicholas Wilson
> wrote:
>> I have a function that takes a large matrix as an out
>> parameter.
>> Is there a way to do `=void` for an out parameter like there
>> is for is for a plain declaration?
>> enum M = 2600;
>> void f() {
>> float[M] mean = void; // works as expected, mean is left
>> uninitialised
>> }
>>
>> void g(out float[M][M] corr) // works but assigns twice
>> {
>> corr[] = float.init; // compiler inserted
>>
>> // assign to each value of corr
>> }
>>
>> //Error: found ')' when expecting '.' following void
>> void h(out float[M][M] corr = void)
>> {
>>
>> }
>>
>> is there a way to not assign to out variables?
>
> Try 'ref' instead of 'out'.
Hmm, I could, but ref doesn't signal intention like out does.
More information about the Digitalmars-d
mailing list