stefanobaghino / lox-interpreter

Interpreter for Lox (https://craftinginterpreters.com) written in Go
0 stars 0 forks source link

Consider using pattern matching for parsing #24

Closed stefanobaghino closed 1 year ago

stefanobaghino commented 1 year ago

Right now, parsing is implemented using the visitor pattern. This is useful writing Java, but it's probably better expressed in Scala using pattern matching. Evaluate this refactoring and possibly implement it. Ideally, write down as a comment which direction you decided to take and why.

stefanobaghino commented 1 year ago

This seems pointing towards the direction given by the book in one of the challenges:

The Visitor pattern lets you emulate the functional style in an object-oriented language. Devise a complementary pattern for a functional language. It should let you bundle all of the operations on one type together and let you define new types easily.

(SML or Haskell would be ideal for this exercise, but Scheme or another Lisp works as well.)

stefanobaghino commented 1 year ago

No longer relevant.