Live data from Hacker News

Things Rust shipped without

graydon2.dreamwidth.org

1–10 of 330 posts

Re: Things Rust shipped without

#4
post #2

What does "unions that allow access to the wrong field" mean?

In C you can store a value to a field of a union and then read from a different field.

This is usually done to "get the byte representation of a float" or things like that.

Except... it's undefined behavior.

Re: Things Rust shipped without

#6
> goto (not even as a reserved word)

I haven't done this for a while, but once upon a graduate program I wrote a compiler from a made-up-language (MUP) to C. MUP had some strange control structures, and if C did not have "goto", it would have been a lot more difficult to implement those structures. Since then, I have always thought languages should have a "goto" statement that human-written code is not allowed to use. :)

Re: Things Rust shipped without

#7
post #6

> goto (not even as a reserved word) I haven't done this for a while, but once upon a graduate program I wrote a compiler from a made-up-language (MUP) to C. MUP had some strange control structures, and if C did not have "goto", it would have been a lot more difficult to implement those structures. Since then, I have always thought languages should have a "goto" statement that human-written code is not allowed to use…

All control flow is ultimately derived from goto (or JMP).

Re: Things Rust shipped without

#8
post #6

> goto (not even as a reserved word) I haven't done this for a while, but once upon a graduate program I wrote a compiler from a made-up-language (MUP) to C. MUP had some strange control structures, and if C did not have "goto", it would have been a lot more difficult to implement those structures. Since then, I have always thought languages should have a "goto" statement that human-written code is not allowed to use…

It often simplifies a lot of the compiler implementation if you only have reducible control flow. LLVM is fine with irreducible control flow, because it has to handle C, but rustc uses a CFG for the borrow checker, which is flow-sensitive. You can convert irreducible control flow to reducible control flow, but it can explode the size of the graph in pathological cases.

(I don't recall whether the borrow checker actually depends on the control flow being reducible, but some of the possible future improvements we've talked about with "non-lexical lifetimes" definitely do. There are also nasty interactions between RAII and irreducible control flow…)

Re: Things Rust shipped without

#10
post #4
post #2

What does "unions that allow access to the wrong field" mean?

In C you can store a value to a field of a union and then read from a different field. This is usually done to "get the byte representation of a float" or things like that. Except... it's undefined behavior.

> Except... it's undefined behavior.

No longer true since C99.

Post reply on HN