7.2
2 Some Racket
We’ll mostly introduce things when we’re going to use them, but we’ll mention a few things here...
We are going to implement an evaluator for a language.
We will write the evaluator in Racket. Racket is pretty lispy and schemey.
The language we will make the evaluator for will also be pretty lispy and schemey.
On the whole: Lispy and schemey.
2.1 Maybe use DrRacket
The Racket installation comes with DrRacket, which you can use for writing and running programs and so on.
It’s pretty nice.
Some things:
Ctrl+\ inserts a λ-character
F1 searches for the name of the identifier your cursor is on in the Racket documentation.
F2 makes a blue box appear! (or disappear)
Ctrl+i indents everything appropriately
Ctrl+↑/{Ctrl+↓} for scrolling through previously used forms in the REPL
2.2 (function argument ...)
There will be stuff like:
(string-append "zeb" "ra")
These are function application-forms.
Each form is a pair of parentheses with some elements between them.
The first element is the function. The other elements are the arguments.
Okay.
2.3 (something-else other-stuff ...)
(if (< 7 x) "lessthan" "notlessthan")
These are not function application-forms, but some other forms.
Good to know.
Anyway, the first element is usually kind of important.
Like if you wanna know what the (define x (+ x 2)) bit does,
it’s probably better to press F1 with the cursor at define and not like at x or something.
Also, in the evaluator we are going to implement, we will totally look at the first element of a form when deciding what to do.
2.4 A very subsetty subset of Racket btw
We will try to write code in a style that isn’t very far away from like, modern Racket, but without introducing an actual ton of Racket.
We get most of the work done by working with lists/pairs and simpler data types like symbols and numbers, and then pattern matching lots.
So like, people who are familiar with Racket-or-Scheme-or-Lisp might read some code and think something like:
Anyway it’s totally okay to use parts of Racket that we don’t mention in the workshop materials.
We don’t have to, but like, we can, it’s fine.