7 ms·
Dynamic dispatch isn't really a replacement for true pattern matching, as pcwalton explains downthread. Local variables (which would be represented as some sort
by nightpool 12y ago
Dynamic dispatch isn't really a replacement for true pattern matching, as pcwalton explains downthread. Local variables (which would be represented as some sort of scope/context object) are one problem, but so is encapsulation. Why would you make the assumption that (X data) knows how to draw itself? What if you're doing something like handling system events? The only true replacement here would be the visitor pattern—which itself is a PITA for a bunch of reasons.