Newsgroups: comp.object,comp.lang.smalltalk,comp.lang.c++,comp.lang.misc
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.kei.com!newsfeed.internetmci.com!in2.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: Wed, 22 Nov 1995 15:21:11 GMT
Message-ID: <1995Nov22.152111.3116@schbbs.mot.com>
References: <48qr06$t79@gaia.ns.utk.edu>
Sender: news@schbbs.mot.com (SCHBBS News Account)
Nntp-Posting-Host: 129.188.128.126
Lines: 63
Xref: glinda.oz.cs.cmu.edu comp.object:41120 comp.lang.smalltalk:30944 comp.lang.c++:161330 comp.lang.misc:23943


In article <48qr06$t79@gaia.ns.utk.edu>  
mbk@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (Matthew B. Kennel) writes:
> Simon Kinahan (simonk@cadence.com) wrote:
> : rtor@ansa.co.uk (Owen Rees) wrote:
> : >If you claim that types and classes are the same, what would you call
> : >whatever it is that has changed when you use 'addSelector'?
> 
> : A dynamic change in type. Type does not have to be a static (ie compile
> : time) concept, it can be a run-time (dynamic) one.
> 
> : Simon
> 
> Presumably then there must be a distinction between 'values' and 'types'. 
> 
> What is it?


Value is the state of an object. If type is a first class object,
a type also has values. It is the state of the type.

Traditiopnally, people do not think that types have states. But
when we dealing with types as objects, it must have states (values)
that can be used to pass and handle the type.

When a type is static, it is a constant object. I.e., its state cannot
be changed during its lifetime. When a type is dynamic, its state
can be changed at runtime.

A static type can still be created at runtime by using run-time values.
But once it is created, its state cannot be changed. For example:

	x : array = 
	    new array 
		< GetDatabaseObjectType(),
		  GetDatabaseSize
		>;

A new array type is created at runtime for "x". The element type and
the size are the states of the array type.

You cannot change the element type or the size of the array type.
An array type is a static type. That is, you cannot have:

	typeof(x).ElementType := aNewtype;
	typeof(x).size := aNewSize;

You can change the type of x by destroying its existing type and
tagging it with a new array type along with a new value. For example:

	ResizeArray (x, newSize);

where the function:

	function ResizeArray
	<type T: array> 
	(a:T, newsize: cardinal): array<T.ElementType,newsize>;

create a new array with a new array type.

David Shang


