Homework #10 Solution Sketches: 1) 4 gcd: 6 ... 4 gcd: 2 ... 2 gcd: 1 and of course there are many many messages passed between each of the above messages. 2) Smalltalk is a "pure" object-oriented language in the sense that everything in the language, including the environment, is an object. There is no way to create an entity that is not an object in Smalltalk. The biggest advantage this provides is uniformity for doing computation: sending message to objects. Such uniformity from the perspective of both the programmer and implementor is absent from so-called OO languages such as C++/Java which require the programmer/implementor to handle classes, objects, interfaces, primitive data types differently. In addition, since a class is an object, it can receive a message to add a selector (method) to itself at run-time, thereby enhancing the scope of computation available to instances of it, again at run-time. Lastly, this design feature also means that "computation about computation" (aka "reflection") is possible (e.g., "ask a class to return all of its selectors -- methods). One disadvantage is the possible reduced efficiency in speed and memory due to the overhead of message passing, esp. in cases where objects are unnecessary (e.g., "2+3"). However, primitive data types and operations (e.g., arithmetic) and constructs (e.g., if-then-else) are likely to be recognized by a Smalltalk interpreter, and actually implemented with special, faster, code. This design decision also pushes most error checks to run-time. For example, the implementation cannot check if a programmer passes a message to an object that does not exist until run-time. The pure object approach also may reduce readability. 3) An operator or function is overloaded if its meaning depends on the number or types of its arguments. E.g., + (real, integer) - (unary, binary) This is sometimes referred to as "ad-hoc polymorphism." Some languages permit overloading of user-defined functions as well. Function overriding (sometimes called "hiding") on the other hand happens when the definition of a function with the same number and type of arguments, in a nested scope, hides the definition of the same function in an outer scope (or in an OO language, when a method of the child class redefines that of the parent class). In a statically scoped language the compiler complains if these two functions definitions do not match in name; and number and type of arguments. Smalltalk has support for overriding through inheritance. Since Smalltalk is untyped and since every selector parameter is prefixed with a keyword, Smalltalk does not support overloading. The closest you can get to overloading in Smalltalk is balance and balance:.