Re: I Break Your Code: No More Uninitialized Variables
[Thread Prev] | [Thread Next]
- Subject: Re: I Break Your Code: No More Uninitialized Variables
- From: Ryan Gonzalez <rymg19@xxxxxxxxx>
- Date: Sat, 12 Dec 2015 10:18:58 -0600
- To: Ori Bernstein <ori@xxxxxxxxxxxxxx>,myrddin-dev@xxxxxxxxxxxxxx
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.
| I Break Your Code: No More Uninitialized Variables | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
- Prev by Date: I Break Your Code: No More Uninitialized Variables
- Next by Date: regression in example on homepage
- Previous by thread: I Break Your Code: No More Uninitialized Variables
- Next by thread: regression in example on homepage
- Index(es):