Live data from Hacker News

Things Rust shipped without

graydon2.dreamwidth.org

11–20 of 330 posts

Re: Things Rust shipped without

#11
post #9
post #3

Earlier quoted context omitted.

union foo { int x; float y; }; union foo bad; bad.x = 100; printf("%f\n", bad.y); // undefined behavior (though usually works)

No undefined behavior. Perfectly legal since C99 standard.

Can we please get a quote on this one. If reinterpreting memory via a union is valid in C99, including data vs function pointers, then so would reinterpreting that memory via a cast, which would seem to violate one of the most elementary aspects of the standard (e.g. such a rule would be difficult or impossible to implement on a Harvard architecture machine, which the standard previously made plenty of allowance for)

Re: Things Rust shipped without

#13
post #10
post #4

Earlier quoted context omitted.

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.

Source please? Or do I need money to get a copy of the standard?

Re: Things Rust shipped without

#15
post #11
post #9

Earlier quoted context omitted.

No undefined behavior. Perfectly legal since C99 standard.

Can we please get a quote on this one. If reinterpreting memory via a union is valid in C99, including data vs function pointers, then so would reinterpreting that memory via a cast, which would seem to violate one of the most elementary aspects of the standard (e.g. such a rule would be difficult or impossible to implement on a Harvard architecture machine, which the standard previously made plenty of allowance for)

Apparently that is correct and I was wrong above (though not in C++) [1]. However, according to the standard, the actual value is unspecified, because float bit representation is undefined.

[1]: http://dbp-consulting.com/tutorials/StrictAliasing.html

Re: Things Rust shipped without

#16
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…

I've used goto in very specific cases which basically boils down to breaking from inner loops to the outside of the outer loop. Thankfully Rust actually has labeled break and continue statements, so this case of using goto is taken care of.

Re: Things Rust shipped without

#18
I'd like Rust to be shipped without counterintuitive standard library function names and that book with all its style 'recommendations'. And I'd like the Rust compiler to be shipped without that non-snake case warning enabled by default.

Language creators won't endear themselves to me by ranting. The problem I have with Rust is _not_ the language itself.

Re: Things Rust shipped without

#19
post #12

What about things that Rust shipped without that should have been included?

Incremental compilation and a non-braindead module system. Breaking changes will be required to fix both, which is why Rust was released too early if you ask me.

Why does incremental compilation require a breaking change? We just sketched a fully compatible design for it last week.

I'd also question why the module system is "braindead", of course.

Post reply on HN