U of I CS 421 - Programming Languages and Compilers (48 pages)

Previewing pages 1, 2, 3, 23, 24, 25, 26, 46, 47, 48 of 48 page document View the full content.
View Full Document

Programming Languages and Compilers



Previewing pages 1, 2, 3, 23, 24, 25, 26, 46, 47, 48 of actual document.

View the full content.
View Full Document
View Full Document

Programming Languages and Compilers

29 views


Pages:
48
School:
University of Illinois
Course:
Cs 421 - Natural Language Processing
Natural Language Processing Documents

Unformatted text preview:

Programming Languages and Compilers CS 421 Elsa L Gunter 2112 SC UIUC http www cs uiuc edu class sp07 cs421 Based in part on slides by Mattox Beckman as updated by Vikram Adve and Gul Agha Records Records serve the same programming purpose as tuples Provide better documentation more readable code Allow components to be accessed by label instead of position Labels aka field names must be unique Fields accessed by suffix dot notation Elsa L Gunter Record Types Record types must be declared before they can be used type person name string ss int int int age int type person name string ss int int int age int person is the type being introduced name ss and age are the labels or fields Elsa L Gunter Record Values Records built with labels order does not matter let teacher name Elsa L Gunter age 102 ss 119 73 6244 val teacher person name Elsa L Gunter ss 119 73 6244 age 102 Elsa L Gunter Record Values let student ss 325 40 1276 name Joseph Martins age 22 val student person name Joseph Martins ss 325 40 1276 age 22 student teacher bool false Elsa L Gunter Record Pattern Matching let name elsa age age ss s3 teacher val elsa string Elsa L Gunter val age int 102 val s3 int 6244 Elsa L Gunter Record Field Access let soc sec teacher ss val soc sec int int int 119 73 6244 Elsa L Gunter New Records from Old let birthday person person with age person age 1 val birthday person person fun birthday teacher person name Elsa L Gunter ss 119 73 6244 age 103 Elsa L Gunter New Records from Old let new id name soc sec person person with name name ss soc sec val new id string int int int person person fun new id Guieseppe Martin 523 04 6712 student person name Guieseppe Martin ss 523 4 6712 age 22 Elsa L Gunter Variants Syntax slightly simplified type name C1 of ty1 Cn of tyn Introduce a type called name fun x Ci x ty1 name Ci is called a constructor if the optional type agrument is omitted it is called a constant Constructors are the basis of almost all pattern matching Elsa L Gunter



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Programming Languages and Compilers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Programming Languages and Compilers and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?