[Pharo-dev] Smalltalk = strongly typed
ennoausberlin at mac.com
Fri Aug 2 15:33:01 EDT 2013
If people ask me about Smalltalk I soon refer to the term duck typing. It perfectly fits.
On 02.08.2013, at 20:55, Igor Stasenko <siguctua at gmail.com> wrote:
> I wonder if 'types' can be applied to smalltalk at all.
> Saying it is 'unityped' language (since everything is an object) is
> same as saying it has no types.
> Because where you need types? When you want to manipulate with data,
> but in smalltalk all
> data manipulation semantics is provided and implemented at primitive
> level, but not by the language itself.
> At language level the only semantics which is defined is message
> passing, closures,
> return and assignment.
> There is no any rule(s), in smalltalk at language level, saying that
> result of expression:
> 1 + 2
> should be of integer type. Because this is provided by implementation
> but not defined by language itself e.g.:
> it is just a method in corresponding class, which implemented in such
> a way that result of expression will be instance of Integer (or
> SmallInteger to be precise).
> Now, if you change implementation so result will be float (or anything
> else), will such change allow you to say, that it is no longer
> smalltalk, or that now it is weakly typed or "anything-else typed"?
> Because smalltalk code do not operates directly with data, but only
> with references to it (which is objects).
> Take an assignment, for example.
> In staticly-typed language assignment copies the value of expression
> to variable, e.g.:
> a = 10
> "now variable a has value = 10"
> in smalltalk, assignment is not copying value, but changing the reference:
> a := 10
> "now variable a points (or refers) to object '10'"
> and thus, whatever 'type' used to represent the integer value 10 is
> completely irrelevant
> for assignment operation.
> Best regards,
> Igor Stasenko.
More information about the Pharo-dev