kmeredith (21) [Avatar] Offline
First off, thanks for writing another Scala book. I learned a lot from DSLs in Action - applying your teachings to building a DSL on my last job.

Chapter 2 mentions:

Encoding this type of implementation using OO and
subtyping will lead us to the path of the Visitor pattern [5], which, as we all know is fraught
with grave perils

As a reader with some Java/.NET experience, but working with Scala the past 1.5 years, I'm not aware of the "grave perils" of the Visitor Pattern.

I believe that it'd please be helpful to present a link or brief mention of the problems of the Visitor Pattern.
Debasish Ghosh (111) [Avatar] Offline
Visitor is one of the most convoluted patterns in GoF. Every one has expressed lots of concerns over the complexity of using this pattern. Just google it and you will find lots of links. However a more interesting topic is to judge how pattern matching is a better alternative when structuring your code. Here are 2 links which you may find useful :-

1. In Defense of Pattern Matching by Martin Odersky (
2. Matching Objects with Patterns (

The second paper gives a comparative analysis of the advantages of using pattern matching over the Visitor pattern in Scala.