lecture-9

lecture-9 - Annoucements Midterm on Tuesday PA 4 due Friday...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Annoucements • Midterm on Tuesday • PA 4 due Friday a week from tomorrow • KQS on Thursday • Dude, what’s KQS? 1 KQS • Handout a sheet with three questions: – what things do you want me to K eep doing? – what things do you want me to Q uit doing? – what things do you want me to S tart doing? • You can fill out answers in prose to these questions. Start thinking early! Deconstructing OCaml What makes up a language Key components of a lang • Units of computation • Types • Memory model Units of computation In OCaml
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 In OCaml • Expressions that evaluate to values • Everything is an expression – int, bool, real – if-then-else – let-in – match – fn x -> x+1 – e1 e2 In Java/Python In Java/Python • Store and update commands • Message sends In Prolog In Prolog • Logical facts • Inference rules Mexican(CARNITAS) Food(CARNITAS) Mexican(X) Food(X) Delicious(X) Delicious(CARNITAS) “Fact” “Fact” “Rule” “Fact” Types
Background image of page 2
3 Types • Used to classify things created by the programmer • Classification used to check what can be done with/to those things In OCaml: Static typing • Types are assigned statically at compile time • Without computing values • Rules state when expressions are type- correct e1 : T1 T2 e2: T1 e1 e2 : T2 In OCaml: Static typing • How can one reuse code for different types? – parametric types: ‘a * ‘b -> ‘b * ‘a – implicit forall • Type “discovered” (inferred) automatically from code – less burden on the programmer In Python: Dynamic typing • Types assigned to values/objects as they are computed, ie: dynamically • Before an operation is performed, check that operands are compatible with operation In Python: Dynamic typing • More programs are accepted by compiler • More flexible, but find errors late let x = if b then 1 else “abc” let y = if b then x + 1 else x ^ “efg” [1, “abc”, 1.8, [ “efg”, 20]] Dynamic vs. Static, OO vs. Func Statically typed Dynamically typed OO Functional
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Dynamic vs. Static, OO vs. Func Statically typed Dynamically typed OO Java Python, Smalltalk, Diesel
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/08/2011 for the course CSE cse130 taught by Professor Cs during the Fall '10 term at UCSD.

Page1 / 9

lecture-9 - Annoucements Midterm on Tuesday PA 4 due Friday...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online