Juha Vihavainen 18.5.2009: 1. Answer the following questions concerning programming languages: (1). Explain the distinctions (if any) between the lifetime, the visibility, and the scope of a name-to-object binding? Give enlightening program examples and explain them thoroughly. - kustakin termistä/kohdasta 1 p - esimerkistä ja sen selostuksesta 1 + 1 p - käsitteiden määrittelyt löytyvät Scottin kirjasta (2) Explain the difference between static and dynamic scope. Why does the use of dynamic scoping imply the need for run-time type checking? Give enlightening program examples and explain them thoroughly. - kustakin termistä/kohtasta 1 p - esimerkistä ja sen selostuksesta 1 + 1 p - käsitteiden määrittelyt löytyvät Scottin kirjasta 4 Explain the terms trait and mix-in in Scala language. Give enlightening program examples and explain them thoroughly. What are the differences between traits and multiple inheritance? What are the differences between traits and Java-style interfaces? Pisteitä suoraan selitettyjen kohtien mukaan. Vastauksen ei tarvitse täysin teknisesti virheetön mutta ei saa olla epämääräinen tai harhaan- johtava. Lisäksi pelkkä asian mainitseminen ei sinällään riitä vaan kohtaan pitää liittyä selitystä. Puolia pisteitä annetaan tarvittaessa. Maksimina 10 pistettä (voi periaatteessa mennä yli). Kustakin Scalan trait-asiakohdasta annetaan yksi piste. Esimerkkejä pisteen antavista tiedoista: - termi trait: definition/explanation - termi mix-in: definition/explanation (various accepted) - can mix-in multiple traits - can be used as interfaces (define polymorphic types) - traits can contain (partial) implementation - can be used as abstract classes (with implemented methods) - traits are not used as independent concrete classes - do not have constructors - trait var and val definitions are inserted into the class - no replication of trait members - a technique to provide "rich interfaces": operations can be defined by a set of abstract "primitives" - description of linearization algorithm to resolve colllisions (at least at some general level) - behaviors can be "stacked" (decorate with capabilities) - override and "super" calls are bound in a flexible way: override/enhance on the trait "to the left" (or the class) - explanation of use of "extends" vs. "with" - mixin in a trait per an instance creation (using anonymous class) - explanation implementation of traits in terms of a Java: interface and an abstract class with code parts - any other relevant fact about Scala traits and mixin use also gives one (1) point - each code example and its explanation (should at least resemble Scala and its semantics) gives 2 p