News for hackers. Stuff that matters.
Re:My gamedever wishlist for Rust by MichaelGG on Thursday October 01, 2015 @01:52PM (#10313047)
>No way to detect at compile-time whether we are in the main thread

Which languages do that? Other than requiring all functions to require a "mainthread" reference (perhaps a zero-sized type that lacks the traits to be sent cross-thread) are there ways to achieve this in general?

Re:My gamedever wishlist for Rust by acconsta on Thursday October 01, 2015 @03:25PM (#10313960)
And... how would that be possible at compile time?
Re:My gamedever wishlist for Rust by MichaelGG on Thursday October 01, 2015 @04:06PM (#10314259)
It's possible at compile time because you won't have the "MainThread" object available unless it's passed in to your other functions. And since you'll deny the traits for sending the object from the main thread to other threads, your methods can never be called.

And if you want it to be optional, like "if mainthread", then just accept an Option of MainThread.

In fact I see exactly this is proposed in the comments on the article: https://users.rust-lang.org/t/my-gamedever-wishlist-for-rust...

Re:My gamedever wishlist for Rust by acconsta on Thursday October 01, 2015 @05:10PM (#10314744)
Oh OK, that's cool. I don't think many languages could enforce that.