Transcript from the "REPLs" Lesson
>> Steve Kinney: We can figure out the structure of our language now. We know what a number is. We know what an identifier is. We know what a expression is. We basically have the very simple structure to our language. We do have some problems that we kind of need to address however.
[00:00:20] We can say, yeah, cool, add two numbers. What does it mean to add two numbers, right? And where are we adding these numbers, right? We're gonna need a few things here. We're gonna need a way to actually use this language. That'd be cool. And we're also gonna need some amount of a standard library, right?
[00:01:00] We can do a lot of stuff with just the language even before the third-party libraries. It's basically the foundation for all of that. So we're gonna do a few things, we're going to build a REPL. I'll talk about what that is. We're gonna build a little CLI tool.
[00:01:34] So what is a REPL? A REPL is a read-evaluate-print loop. REPL, [LAUGH] it's an acronym, and it does what it says. Basically, you give it some expression, it reads it, it evaluates it, right, which is the part we have not implemented yet. We can parse but we don't and once we have the structure, we need to actually then execute it, right?
[00:02:02] And then once you've executed it, it's effectively printing something to the screen saying something happened. You can run a function but if you don't tell anyone did it really happen? And then once we have read, evaluated and printed the result then we give him another prompt, right? And we allow them to go ahead and play the whole game over.
[00:02:24] You have used a REPL at some point of your life likely. Node has a REPL built in. If you just type node, you'll get one where you can start typing things. Python, Ruby, almost every language I can think of has one. So we are gonna need a few things in place.
[00:02:41] I kind of alluded to in the ramp up to this. We've just been taking for granted that there's a add function in the language, right, or a subtract function in the language, right? There can be [LAUGH]. We're the ones making this language and it means that we got to put them in there, right?
[00:03:35] In we have a little bit differently cuz we don't necessarily have operators in our language. Everything is a function expression currently in a list. And we know that our add or subtract can take an unlimited series of arguments. So we'll have to do a little bit of work.
[00:03:50] Now, some of that I've done for you. It's what I care more about is the wiring up. I'll take you on a tour. And then once I've taken you on a tour of some of the kind of structure that I've built, we'll talk a little bit about, okay, now how do we actually go ahead and evaluate this language.
[00:04:04] So let's actually look at some of the code that we have in the quote-unquote standard library. And you'll be able to add stuff to the standard library in.