loading...

re: What are the hardest programming languages you have ever learned? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: It has too many underscores and it doesn't support global variables.

What is a global variable, in this context, and why would one use it?

A global variable is a variable that can be read and written from everything inside your application and it is awesome for saving states. Sadly, Rust does not know the concept of "static globals".

Just initialize whatever you want to share in the main function and pass it in to where it's needed?

I'm sorry if I sound dismissive, it just really doesn't sound like a good idea.
Words like implicit dependency, side effect, singleton, and not thread safe come to mind.
Why touch something that wasn't passed into your function?

It's definitely not the same, I agree.
Can you give an example of when you'd want to use one?

code of conduct - report abuse