Why do we use S-expressions for syntax? It has a certain convenience, but the students pay for it in any number of small ways. How many times do they end up with "extra parentheses", because non-type-safe operations are applied to expressions in list form?
If anything, struct-based pattern matching is actually cleaner in racket than quasiquoted list patterns:
#lang racket
(struct foo (a b))
(match (foo 1 2)
[(foo a b) a])
Struct based ASTs would be a major change to the book, so it shouldn't be undertaken lightly. As a stop-gap I have recommended that students make more defensive helper functions like "append two lists of instructions" that use a contract to (deeply) check the validity of their inputs.
Presently, list-based S-expressions combine with the slightly underspecified grammars (#29) to create deviations between the student compilers and the textbook (more importantly, the expectations of the testing-framework / interpreters).
Disadvantages / Alternatives
Aside from the cost of the change itself:
Reading input programs from SExpressions would require a basic "parser" pass that convers sexp->structs. This is probably a good practice anyway, like the old "parse-scheme" pass.
Why do we use S-expressions for syntax? It has a certain convenience, but the students pay for it in any number of small ways. How many times do they end up with "extra parentheses", because non-type-safe operations are applied to expressions in list form?
If anything, struct-based pattern matching is actually cleaner in racket than quasiquoted list patterns:
Struct based ASTs would be a major change to the book, so it shouldn't be undertaken lightly. As a stop-gap I have recommended that students make more defensive helper functions like "append two lists of instructions" that use a contract to (deeply) check the validity of their inputs. Presently, list-based S-expressions combine with the slightly underspecified grammars (#29) to create deviations between the student compilers and the textbook (more importantly, the expectations of the testing-framework / interpreters).
Disadvantages / Alternatives
Aside from the cost of the change itself: