Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[derive(UserData)] #1

Open
andrewcsmith opened this issue Apr 2, 2018 · 2 comments
Open

#[derive(UserData)] #1

andrewcsmith opened this issue Apr 2, 2018 · 2 comments

Comments

@andrewcsmith
Copy link
Owner

UserData is basically all boilerplate...

@giuliomoro
Copy link

it's also mostly unused!
In principle, it could be used by the wrapping main() to pass arguments to setup(), render(), cleanup(), but in practice many times global variables can do the same job.

@andrewcsmith
Copy link
Owner Author

@giuliomoro for an idiomatic API, we should actually eliminate global variables altogether. Mutable global variables are unsafe in Rust (and, technically, in general) since they're both mutable and shared. Basically, for this library anyway, even the callback functions are stored in UserData!

What I meant in this issue is that all the bits of UserData that define the callbacks should probably be provided by a macro, rather than by writing out those complicated signatures by hand. The idea here is that the type-safety of Rust guarantees at compile time that you're always using the same struct for UserData.

I'm hoping to teach a workshop to my class at UCSC, and I'll pull the stuff together for the internet...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants