digitalmars.D.bugs - [Issue 17765] New: void initialisation of out parameters
- via Digitalmars-d-bugs (39/39) Aug 19 2017 https://issues.dlang.org/show_bug.cgi?id=17765
https://issues.dlang.org/show_bug.cgi?id=17765 Issue ID: 17765 Summary: void initialisation of out parameters Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: iamthewilsonator hotmail.com Out variables are always initialised, but when they are large static arrays this incurs a performance penalty. For declaration of regular variables we have = void to stop default initialisation. This does not work for out variables. This ER suggests to make `i` valid syntax to suppress initialisation of the out variable. 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 } // only assigns once but does not signal intention like out does // also is valid to read from `corr` as opposed to write only like `g` void h(ref float[M][M] corr) { // assign to each value of corr } //Error: found ')' when expecting '.' following void void i(out float[M][M] corr = void) { // assign to each value of corr } --
Aug 19 2017