Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I Break Your Code: No More Uninitialized Variables



On December 12, 2015 12:52:28 AM CST, Ori Bernstein <ori@xxxxxxxxxxxxxx> wrote:
>Variables must now be initialized before use.
>
>This was the case before now, but the compiler checks as of today. This
>code is no longer valid:
>
>	const f = {
>		var x
>
>		use(x)
>	}
>
>This has already led to fixing two bugs in the standard distribution.
>
>The change breaks one legitimate use from libstd, and I'd be open to
>clean
>ways to fix it, since it's already ugly:
>
>	var dummy : mytype
>
>	std.fmtinstall(std.typeof(dummy), fmtfunc)
>

Maybe you could add a keyword that goes after var and zeroes the variable. Like:

var 0 dummy: mytype /* mytype is now zero-initialized */

Or at least for structs.

>For now, I worked around it by initializing a few spurious values and
>free
>them when installing format funcs.
>
>I'm currently thinking that the entire introspection API needs an
>overhaul.

-- 
Sent from my Nexus 5 with K-9 Mail. Please excuse my brevity.

References:
I Break Your Code: No More Uninitialized VariablesOri Bernstein <ori@xxxxxxxxxxxxxx>