Chris Lattner
๐ค SpeakerAppearances Over Time
Podcast Appearances
And by doing that, what you can say is you can say, OK, if I'm defining something weird, like an atomic number or something, it's like, eh.
So an atomic number is an area in memory that multiple threads can access at a time without locks.
And so the definition of an atomic number is multiple different things have to be poking at that, therefore they have to agree on where it is.
So you can't just like move it out from underneath one because it kind of breaks what it means.
And so that's an example of a type that you can't even, you can't copy, you can't move it.
Like once you create it, it has to be where it was, right?
Now, if you look at many other examples, like a database sample, right?
So, okay, well, what happens
How do you copy a database handle?
Do you copy the whole database?
That's not something you necessarily want to do.
There's a lot of types like that where you want to be able to say that they are uniquely owned.
So there's always one of this thing.
Or if I create a thing, I don't copy it.
And so what Mojo allows you to do is it allows you to say,
hey, I want to pass around a reference to this thing without copying it.
And so it has borrowed conventions.
So you can say you can use it, but you don't get to change it.
You can pass it by mutable reference.
And so if you do that, then you get a reference to it, but you can change it.