Newsgroups: comp.object,comp.lang.smalltalk,comp.lang.c++,comp.lang.misc
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!news.ecn.bgu.edu!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in1.uu.net!mdisea!mothost!schbbs!news
From: shang@corp.mot.com (David L. Shang)
Subject: Re: Types, types: static vs. dynamic -- classification
Reply-To: shang@corp.mot.com
Organization: MOTOROLA 
Date: Thu, 30 Nov 1995 15:49:15 GMT
Message-ID: <1995Nov30.154915.13696@schbbs.mot.com>
References: <ccs.peeraer.g.57.0010B6CA@alpha.ufsia.ac.be>
Sender: news@schbbs.mot.com (SCHBBS News Account)
Nntp-Posting-Host: 129.188.128.126
Lines: 53
Xref: glinda.oz.cs.cmu.edu comp.object:41682 comp.lang.smalltalk:31313 comp.lang.c++:162651 comp.lang.misc:24031

In article <ccs.peeraer.g.57.0010B6CA@alpha.ufsia.ac.be>  
ccs.peeraer.g@alpha.ufsia.ac.be (Geert Peeraer) writes:
> In article <1995Nov27.170252.10232@schbbs.mot.com> shang@corp.mot.com (David  
L. Shang) writes:
> 
> >> >David> When a type is static, it is a constant object. I.e., its state
> >> >David> cannot be changed during its lifetime. When a type is dynamic,
> >> >David> its state can be changed at runtime.
> I can see your point when i read "structure" instead of "state" and when 
> I think of a smalltalk like environment. But is a smalltalk like type really 
> dynamic or is it only  dynamic during development. Once a development 
> finishes, you stop using dynamic types?

Structure is the template for the shape of the object. Though type
specifies structures, it's hard to say that the strcuture is the state
of a type, because structure has no embodied value that you can pass
it from one place to another. The only thing you can handle in value is
the building blocks of the structure, for example, slots. Adding, modifying,
or deleting slots will change the structure. However, slots are not
something belonging to a type. The thing belonging to type is the way
those slots are arranged, that is, the structure. But structure is not
a state.

So many people think that types have no states.

Does a type have state? Yes. SmallTalk class has meta members. They are
states of a type.

What else are meta members? Consider a generic type array<T>, T is the
state of the type. You can change the state (value) of T (note that type
is a first-class object) so that the structure of the array is changed.
Suppose I have a type varaible:

	type a: array := array<integer>;

We then can change its state (the element type) by:

	a.T := float;

However, this kind of change will create lots of problems. Therefore,
in Trnasframe, class parameters are constant state of a type. Once
it is associated with a concrete type, it can no longer be changed.
If you want to change it, you actually created a new type and the
old type is destroyed (or precisely, garbage collected).

What are benefits to have type states? Two majors: You get powerful
dynamic genericity -- an efficient dynamic typing. Also you can
describe the a precise type dependency in an interface so that
many run-time type errors detected in C++, Java, Eiffel, etc,
could be detected before runtime.

David Shang

