David Masover wrote: > And yes, it's going to be a ginormous case statement anyway. I'd much > rather > use polymorphism than case statements any day. The problem then is that you're mixing the data structure with the actions you want to perform using it, like mixing a model with a controller. I'm finding myself more attracted to having data structures entirely separate from functions which act on that data, because you never have to reconcile this dichotomy. e.g. in Erlang you could just write: -module(visit). -export([eval/1]). eval({badd, S1, S2}) -> eval(S1) + eval(S2); eval({bmul, S1, S2}) -> eval(S1) * eval(S2); eval({int, V}) -> V. Eshell V5.6.5 (abort with ^G) 1> c(visit). {ok,visit} 2> %% Tree for 2 + 3 * 4 2> Tree = { badd, {int, 2}, { bmul, {int, 3}, {int, 4} } }. {badd,{int,2},{bmul,{int,3},{int,4}}} 3> visit:eval(Tree). 14 Essentially you still have the big fat case statement, but it's written as a function with pattern-matched entry points. All the logic for evaluating the tree is in one place. For someone used to Ruby, Erlang syntax is still annoying though :-( -- Posted via http://www.ruby-forum.com/.