Dan grossman d grossman because java an all 2011 and

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s Mechanics dynamically select tML Variable Bindings method he correct visit ML Variable Bindings based on the runVme type of node? Dan Grossman D Grossman •  Because Java an all 2011 and many other OO (F C++, Fall 2011 and languages) use single dispatch. –  In other words, dynamic dispatch in Java is based on the run- Vme type of a single object, namely the receiver, i.e, x in x.foo(y, z)! Winter 2013 UW CSE 401 (Michael Ringenburg) 3 Two Code Samples classCSE341: Programming class WhileNd extends StmtNd { WhileNd extendsCSE341: Programming Languages StmtNd { Languages ExpNd cond; ExpNd cond; } oid accept(Visitor v) {v.visit(this);} Lecture 1 vLecture 1 } Course Mechanics Course Mechanics visit(WhileNd w) { void visit(WhileNd w) { void ML Variable Bindings M visit(w.cond); L Variable Bindings w.cond.accept(this); } } Dan Grossman Dan Grossman Fall 2011 •  Selects visit based on •  Selects accept based on...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online