You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this great book. Just started reading the Racket book and I had a question regarding Section 1.2 (page 4). The AST examples are written in a format that is similar to the BNF grammar, and are not Racket code. Is that intentional?
For example, the AST for negative 8 is represented as this:
(Prim '- ((Int 8)))
The equivalent Racket code would be
(Prim '- (list (Int 8)))
I'm learning Racket at the same time, and I was wondering why we don't use Racket to represent the AST. Thanks!
The text was updated successfully, but these errors were encountered:
siadat
changed the title
Question about AST formats in the Racket book
Question about AST formats in the Racket book section 1.2
May 20, 2024
It looks like I forgot the single-quote in a bunch of places.
That is, in Racket, '(1 2 3)
is another way to write (list 1 2 3)
I'll look into fixing this when I get back from vacation.
Thanks! In the grammar, (exp) represents a list with one expression, which matches the ASTs. So, if we update the ASTs we might want to consider updating the grammar as well, perhaps to something like this:
exp ::= (Prim '- (list exp))
Just an observation regarding single-quote vs list: with single-quote the expressions inside the list get quoted as well and the result may be different, e.g. (list (+ 1 2) 3) != '((+ 1 2) 3).
I am excited to continue to follow the book this week. Enjoy your vacation! :)
Thanks for this great book. Just started reading the Racket book and I had a question regarding Section 1.2 (page 4). The AST examples are written in a format that is similar to the BNF grammar, and are not Racket code. Is that intentional?
For example, the AST for negative 8 is represented as this:
The equivalent Racket code would be
I'm learning Racket at the same time, and I was wondering why we don't use Racket to represent the AST. Thanks!
The text was updated successfully, but these errors were encountered: