SEN308 Lecture 8
SEN308 Lecture 8
SEN308 Lecture 8
• Objects of this new class also need a draw method that is like that
provided by A but a bit different because the subclass objects are
slightly different.
• So, the subclass overrides the inherited draw method. If a client of A
and B has a variable that is a reference to class A’s objects, that
reference also could point at class B’s objects, making it a
polymorphic reference. If the method draw, which is defined in both
classes, is called through the polymorphic reference, the run-time
system must determine, during execution, which method should be
called, A’s or B’s
• The only type checking in Smalltalk is dynamic, and the only type error occurs
when a message is sent to an object that has no matching method, either locally
or through inheritance.
• This is a different concept of type checking than that of most other languages.
Smalltalk type checking has the simple goal of ensuring that a message matches
some method.
• Smalltalk variables are not typed; any name can be bound to any object.
• As a direct result, Smalltalk supports dynamic polymorphism. All Smalltalk code is
generic in the sense that the types of the variables are irrelevant, as long as they
are consistent.
• The meaning of an operation (method or operator) on a variable is determined by
the class of the object to which the variable is currently bound.
Concepts of Programming Languages - NUN 2024 Austin Olom Ogar
Evaluation of Smalltalk
• Smalltalk is a small language, although the Smalltalk system is large. The syntax of
the language is simple and highly regular.
• It is a good example of the power that can be provided by a small language if that
language is built around a simple but powerful concept. In the case of Smalltalk,
that concept is that all programming can be done employing only a class
hierarchy built using inheritance, objects, and message passing
• In comparison with conventional compiled imperative- language programs,
equivalent Smalltalk programs are significantly slower.
• Although it is theoretically interesting that array indexing and loops can be
provided within the message- passing model, efficiency is an important factor in
the evaluation of programming languages. Therefore, efficiency will clearly be an
issue in most discussions of the practical applicability of Smalltalk.
• General Characteristics:
• Mixed typing system
• Constructors and destructors
• Elaborate access controls to class entities
• Inheritance
• A class need not be subclasses of any class
• Access controls for members are
1. Private (visible only in the class and friends)
2. Public (visible in subclasses and clients)
3. Protected (visible in the class and in subclasses)
• In addition, the subclassing process can be declared with access controls, which define
potential changes in access by subclasses
• Multiple inheritance is supported