Final End of Multi-methods
• Fri 11:30 – 2:30 – Here
• practice problems and sample final up on method equals(@Shape, @Shape):boolean { false } the web method equals(r1@Rect, r2@Rect) { ... } method equals(r1@Tri, r2@Tri) { ... } • Review session – some of it today, TA and I will hold special office hours next week for help
In perl 6 In Java (called Multi-Java)
class Test { class Shape { multi method what_is_it(Int $x) { public boolean equals(Shape@Shape) { return false } say "This is the integer $x"; } } multi method what_is_it(Str $s) { class Rect extends Shape { say "This is the string $s“; public boolean equals(Shape@Rect r) { ... } } } } class Circle extends Shape { my Test $t .= new(); public boolean equals(Shape@Circle c) { ... } $t.what_is_it(42); # This is the integer 42 } $t.what_is_it("weasel"); # This is the string weasel
What’s on the final
• Programming questions Short Review Session • In Ocaml • In Python • In Prolog • Other kinds of questions too…
1 What’s on the final (cont’d) Open book?
• know how to … figure out ML types • No, but you may bring a cheat sheet • ... write decorators and python code • … write prolog predicates • know stuff about OO types (contra/covariant)
• look at previous finals • test your solutions by hand
Recap
Functional
• No mutation! Instead have environments Functional • Higher order programming (functions as params and returned values)
• map and fold goodness
• type system and type inference
2 Python
• Dynamic dispatch Object Oriented • Inheritance • Decorators
Constraint based programming
• What do you think of Prolog? Prolog • Totally different model of computation • Way cool, if you ask me! • But can be hard to program in...
What makes us like a language? What makes us like a language?
• Type system? • Convenient shortcuts (Perl) ? • Simplicity? – at odds with convenient shortcuts • Orthogonality (language features don’t clash) – also at odds with convenient shortcuts • Libraries? (very important one)
3 Course Goals Course goals, achieved?
“Free your mind” • What new things have you learned? -Morpheus
You will learn several new - languages and constructs - ways to describe and organize computation
Yes, you can do that in Java/Assembly but …
Ok, that’s it folks
• Did my best to try to teach you something new.
• Hope this class was enjoyable, and that you learned something.
4