Menu
Sign In Search Podcasts Charts People & Topics Add Podcast API Blog Pricing

Chris Lattner

๐Ÿ‘ค Speaker
See mentions of this person in podcasts
2524 total appearances

Appearances Over Time

Podcast Appearances

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so you have...

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Function one calls function two, calls function three, calls function four.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Along that call stack, there are try blocks, right?

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so if you have function one calls function two, function two has a try block, and then within it, it calls function three, right?

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Well, what happens if function three throws?

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Well, actually, start simpler.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

What happens if it returns?

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Well, if it returns, it's supposed to go back out and continue executing and then fall off the bottom of the try block and keep going and all's good.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

If the function throws, you're supposed to exit the current function and then get into the accept clause, right?

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And then do whatever code's there and then keep falling on and going on.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so the way that a compiler like Mojo works is that the call to that function, which happens in the accept block, calls the function, and then instead of returning nothing, it actually returns a variant between nothing and an error.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so if you return normally, fall off the bottom or do return,

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

You return nothing, and if you throw an error, you return the variant that is, I'm an error.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

So when you get to the call, you say, okay, cool, I called a function.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Hey, I know locally I'm in a try block.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so I call the function, and then I check to see what it returns.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Aha, if it's that error thing, jump to the accept block.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

Exactly.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And so the compiler does all this for you.

Lex Fridman Podcast
#381 โ€“ Chris Lattner: Future of Programming and AI

And, I mean, one of the things, if you dig into how this stuff works in Python, it gets a little bit more complicated because you have finally blocks, which now you need to go into, do some stuff, and then...