Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The most important distinction in a language is

Name: Anonymous 2015-10-10 13:46

whether it has GC or not.

Name: Anonymous 2015-10-15 18:04

>>19
No, take a look at the vulkan thread.
That was literally one guy complaining because he was trying to write his own bindings and didn't know how to make it work. If he was serious about his project he would have just used the unsafe memory manipulation functions in the Rust standard library, like everyone else does (at least until a convenient solution is available).

Point being, it's not that Rust is incapable of doing certain things. It's just that this one guy didn't know how to do them.

Name: Anonymous 2015-10-15 20:17

>>42
It's just that this one guy didn't know how to do them.

It's a little more than that. He needed to provide the functionality in a seamless way to library consumers without adding overhead. It can be done, but you end up with a convoluted solution and will have to rely on the optimizer to fix it up for you. He should complain, but not at the Vulkan people, except about the actual API deficiencies.

Name: Anonymous 2015-10-16 10:41

I'd comment on the language, but I'm a bit rusty.

Name: Anonymous 2015-10-16 12:30

>>43,42
provide the functionality in a seamless way to library consumers without adding overhead
he would have just used the unsafe memory manipulation functions
Overhead my foot

Name: Anonymous 2015-10-16 16:24

>>45
Are you an idiot? Yes, he can use the unsafe functions, but he's writing a (safe) library that has to provide access to this information. It's right there in the text you quoted.

It turns out Rust can manage this, at least for unions with a small number of variants. This depends on having better inlining and related optimizations than Clang at -O2, not something I expected. My first test eliminated all of the code since the results weren't used.

But I would never use this technique. Defining the union in Rust was hard and accessing it would break on other machines. One of the few safety features they try to assert in unsafe Rust keeps you from accessing data of the wrong size for the type. Unions fuck that shit right up because you have to describe a struct with non-overlapping fields in Rust to get the repr sized right. It might be impossible to reclaim performance with certain layouts.

If I absolutely had to deal with it I would either write an inefficient wrapper in C (return a struct with all union fields laid out sequentially, i.e. no union) or, if performance/memory was paramount I would push the minimum of logic into a C switch. Since Rust's ABI is unspecified you can't just return enum values out of the switch, so it would have to be more involved than that.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List