Article View: comp.lang.misc
Article #3226Re: CHALLENGE: heterogeneous collections
From: Darren New
Date: Wed, 27 Mar 1991 20:29
Date: Wed, 27 Mar 1991 20:29
63 lines
4350 bytes
4350 bytes
In article <26MAR91.19392004@uc780.umd.edu> cs450a03@uc780.umd.edu writes:
>>Hmm... a homogenous collection that when you take it apart yields things
>>with different types. Somehow, I think we are confused over terminology.
>Well.. my view is "type is a form of information", and you seem to be
>agreeing with me.
Well, heck, cowboy. Of course type is a form of information. But is
it information only the compiler has, or is it information that comes
into play at run-time. The question is essentially whether variables
have types or not. If not, then you have dynamic typing. If so, then
you have static typing, because each particular reference (variable,
expression, etc) has a known type at compile time. Of course if you
can apply different functions to different elements of the list based
on their type, then "type" is a kind of information you can access,
whether that information is accessed only by the runtime system or
whether it is directly accessible to the programmer.
When you say something is a homogenous collection, you seem to be
saying that every element is a <type,value> pair and hence is all the
same type. Naturally in a dynamically typed system, the types have to
be carried along with the values in some way. However, variables and
expressions (in this case, expressions accessing elements of the list)
have different <type> tags. The fact that the type of the first element
of <type,value> is of a fixed type does not mean that the elements all
have the same type (did that make any sense?).
Take, for example, Smalltalk. You can say "it's statically typed, because
every variable and every value is an object." This, of course, is useless.
Why? Because when you only have one type, the static/dynamic distinction
becomes irrelevant. (I believe this is actually the case in older lisps,
where everything was a cons cell.) Any Smalltalk programmer is going to
think of the class of an object as its type. Since variables can hold
objects from different classes and since expressions can return objects
of different classes, Smalltalk is dynamically typed. Naturally,
any object's class is going to be an instance of Behavour, so it will
repond to anything Behavour's instances respond to. Hence, the type of
a type (i.e., class) is always of a specific type (namely, Behavour).
This does not alter the dynamicly-typed nature of Smalltalk.
Arguing this from the wrong viewpoint is pointless, as at the lowest
level, the only type in computer systems is the bit (and not even that,
if you talk to an EE person). At the highest level (e.g., Vice
President of Marketing), the only type is "information." Since most
programmers work somewhere inbetween these two levels, it is necessary
to pick the right level of abstraction for discussing types. (Kind of
like saying "The halting problem is solvable in practice. All you have
to do is treat every bit of storage ever accessed by the CPU running
your program as a giant state machine." Nobody ever thinks about the
problem this way, and nobody ever programs a computer as a
2^{8gig}-state finite state machine, so such a statement, while true,
is pretty much useless.) At the lowest level, the machine can treat the
<type> tag as an integer or pointer or whatever. However, that isn't
usually how the programmer treats it. If you want to discuss various
forms of dynamic typing, we would need a different level of abstraction
than if we are discussing dynamic vs. static typing.
-- Darren
--
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, FDTs -----
+=+=+ My time is very valuable, but unfortunately only to me +=+=+
+ When you drive screws with a hammer, screwdrivers are unnecessary +
Technical Details
Message-ID:
<49078@nigel.ee.udel.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!ee.udel.eduReferences:
<25MAR91.22422777@uc780.umd.edu> <48913@nigel.ee.udel.edu> <26MAR91.19392004@uc780.umd.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!ee.udel.edu From: new@ee.udel.edu (Darren New) Newsgroups: comp.lang.misc Subject: Re: CHALLENGE: heterogeneous collections Message-ID: <49078@nigel.ee.udel.edu> Date: 27 Mar 91 20:29:39 GMT References: <25MAR91.22422777@uc780.umd.edu> <48913@nigel.ee.udel.edu> <26MAR91.19392004@uc780.umd.edu> Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 63 Nntp-Posting-Host: snow-white.ee.udel.edu